summaryrefslogtreecommitdiffstats
path: root/lib/lwres/man/lwres_getipnode.3
blob: e5c51a999cc23a585bb5db44c47b4899e031010c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
.\" Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
.\" 
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\" 
.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
.\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
.\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
.\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
.\" $Id: lwres_getipnode.3,v 1.28 2007/01/30 00:24:59 marka Exp $
.\"
.hy 0
.ad l
.\"     Title: lwres_getipnode
.\"    Author: 
.\" Generator: DocBook XSL Stylesheets v1.71.1 <http://docbook.sf.net/>
.\"      Date: Jun 30, 2000
.\"    Manual: BIND9
.\"    Source: BIND9
.\"
.TH "LWRES_GETIPNODE" "3" "Jun 30, 2000" "BIND9" "BIND9"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.SH "NAME"
lwres_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent \- lightweight resolver nodename / address translation API
.SH "SYNOPSIS"
.nf
#include <lwres/netdb.h>
.fi
.HP 39
.BI "struct hostent * lwres_getipnodebyname(const\ char\ *" "name" ", int\ " "af" ", int\ " "flags" ", int\ *" "error_num" ");"
.HP 39
.BI "struct hostent * lwres_getipnodebyaddr(const\ void\ *" "src" ", size_t\ " "len" ", int\ " "af" ", int\ *" "error_num" ");"
.HP 23
.BI "void lwres_freehostent(struct\ hostent\ *" "he" ");"
.SH "DESCRIPTION"
.PP
These functions perform thread safe, protocol independent nodename\-to\-address and address\-to\-nodename translation as defined in RFC2553.
.PP
They use a
\fBstruct hostent\fR
which is defined in
\fInamedb.h\fR:
.PP
.RS 4
.nf
struct  hostent {
        char    *h_name;        /* official name of host */
        char    **h_aliases;    /* alias list */
        int     h_addrtype;     /* host address type */
        int     h_length;       /* length of address */
        char    **h_addr_list;  /* list of addresses from name server */
};
#define h_addr  h_addr_list[0]  /* address, for backward compatibility */
.fi
.RE
.sp
.PP
The members of this structure are:
.PP
\fBh_name\fR
.RS 4
The official (canonical) name of the host.
.RE
.PP
\fBh_aliases\fR
.RS 4
A NULL\-terminated array of alternate names (nicknames) for the host.
.RE
.PP
\fBh_addrtype\fR
.RS 4
The type of address being returned \- usually
\fBPF_INET\fR
or
\fBPF_INET6\fR.
.RE
.PP
\fBh_length\fR
.RS 4
The length of the address in bytes.
.RE
.PP
\fBh_addr_list\fR
.RS 4
A
\fBNULL\fR
terminated array of network addresses for the host. Host addresses are returned in network byte order.
.RE
.PP
\fBlwres_getipnodebyname()\fR
looks up addresses of protocol family
\fIaf\fR
for the hostname
\fIname\fR. The
\fIflags\fR
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:
.PP
\fBAI_V4MAPPED\fR
.RS 4
This is used with an
\fIaf\fR
of AF_INET6, and causes IPv4 addresses to be returned as IPv4\-mapped IPv6 addresses.
.RE
.PP
\fBAI_ALL\fR
.RS 4
This is used with an
\fIaf\fR
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.
.RE
.PP
\fBAI_ADDRCONFIG\fR
.RS 4
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.
.RE
.PP
\fBAI_DEFAULT\fR
.RS 4
This default sets the
\fBAI_V4MAPPED\fR
and
\fBAI_ADDRCONFIG\fR
flag bits.
.RE
.PP
\fBlwres_getipnodebyaddr()\fR
performs a reverse lookup of address
\fIsrc\fR
which is
\fIlen\fR
bytes long.
\fIaf\fR
denotes the protocol family, typically
\fBPF_INET\fR
or
\fBPF_INET6\fR.
.PP
\fBlwres_freehostent()\fR
releases all the memory associated with the
\fBstruct hostent\fR
pointer
\fIhe\fR. Any memory allocated for the
\fBh_name\fR,
\fBh_addr_list\fR
and
\fBh_aliases\fR
is freed, as is the memory for the
\fBhostent\fR
structure itself.
.SH "RETURN VALUES"
.PP
If an error occurs,
\fBlwres_getipnodebyname()\fR
and
\fBlwres_getipnodebyaddr()\fR
set
\fI*error_num\fR
to an appropriate error code and the function returns a
\fBNULL\fR
pointer. The error codes and their meanings are defined in
\fI<lwres/netdb.h>\fR:
.PP
\fBHOST_NOT_FOUND\fR
.RS 4
No such host is known.
.RE
.PP
\fBNO_ADDRESS\fR
.RS 4
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.
.RE
.PP
\fBTRY_AGAIN\fR
.RS 4
A temporary and possibly transient error occurred, such as a failure of a server to respond. The request may succeed if retried.
.RE
.PP
\fBNO_RECOVERY\fR
.RS 4
An unexpected failure occurred, and retrying the request is pointless.
.RE
.PP
\fBlwres_hstrerror\fR(3)
translates these error codes to suitable error messages.
.SH "SEE ALSO"
.PP
\fBRFC2553\fR(),
\fBlwres\fR(3),
\fBlwres_gethostent\fR(3),
\fBlwres_getaddrinfo\fR(3),
\fBlwres_getnameinfo\fR(3),
\fBlwres_hstrerror\fR(3).
.SH "COPYRIGHT"
Copyright \(co 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
.br
Copyright \(co 2000, 2001, 2003 Internet Software Consortium.
.br