]> git.ipfire.org Git - people/ms/strongswan.git/blame - src/libfreeswan/liblwres/man/lwres_getipnode.3
- started to rebuild source layout
[people/ms/strongswan.git] / src / libfreeswan / liblwres / man / lwres_getipnode.3
CommitLineData
997358a6
MW
1.\"
2.\" Copyright (C) 2000, 2001 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 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.
16.\"
17.TH "LWRES_GETIPNODE" "3" "Jun 30, 2000" "BIND9" ""
18.SH NAME
19lwres_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent \- lightweight resolver nodename / address translation API
20.SH SYNOPSIS
21\fB#include <lwres/netdb.h>
22.sp
23.na
24struct hostent *
25lwres_getipnodebyname(const char *name, int af, int flags, int *error_num);
26.ad
27.sp
28.na
29struct hostent *
30lwres_getipnodebyaddr(const void *src, size_t len, int af, int *error_num);
31.ad
32.sp
33.na
34void
35lwres_freehostent(struct hostent *he);
36.ad
37\fR.SH "DESCRIPTION"
38.PP
39These functions perform thread safe, protocol independent
40nodename-to-address and address-to-nodename
41translation as defined in RFC2553.
42.PP
43They use a
44\fBstruct hostent\fR
45which is defined in
46\fInamedb.h\fR:
47.sp
48.nf
49struct hostent {
50 char *h_name; /* official name of host */
51 char **h_aliases; /* alias list */
52 int h_addrtype; /* host address type */
53 int h_length; /* length of address */
54 char **h_addr_list; /* list of addresses from name server */
55};
56#define h_addr h_addr_list[0] /* address, for backward compatibility */
57.sp
58.fi
59.PP
60The members of this structure are:
61.TP
62\fBh_name\fR
63The official (canonical) name of the host.
64.TP
65\fBh_aliases\fR
66A NULL-terminated array of alternate names (nicknames) for the host.
67.TP
68\fBh_addrtype\fR
69The type of address being returned - usually
70\fBPF_INET\fR
71or
72\fBPF_INET6\fR.
73.TP
74\fBh_length\fR
75The length of the address in bytes.
76.TP
77\fBh_addr_list\fR
78A
79\fBNULL\fR
80terminated array of network addresses for the host.
81Host addresses are returned in network byte order.
82.PP
83\fBlwres_getipnodebyname()\fR
84looks up addresses of protocol family
85\fIaf\fR
86for the hostname
87\fIname\fR.
88The
89\fIflags\fR
90parameter contains ORed flag bits to
91specify the types of addresses that are searched
92for, and the types of addresses that are returned.
93The flag bits are:
94.TP
95\fBAI_V4MAPPED\fR
96This is used with an
97\fIaf\fR
98of AF_INET6, and causes IPv4 addresses to be returned as IPv4-mapped
99IPv6 addresses.
100.TP
101\fBAI_ALL\fR
102This is used with an
103\fIaf\fR
104of AF_INET6, and causes all known addresses (IPv6 and IPv4) to be returned.
105If AI_V4MAPPED is also set, the IPv4 addresses are return as mapped
106IPv6 addresses.
107.TP
108\fBAI_ADDRCONFIG\fR
109Only return an IPv6 or IPv4 address if here is an active network
110interface of that type. This is not currently implemented
111in the BIND 9 lightweight resolver, and the flag is ignored.
112.TP
113\fBAI_DEFAULT\fR
114This default sets the
115AI_V4MAPPED
116and
117AI_ADDRCONFIG
118flag bits.
119.PP
120\fBlwres_getipnodebyaddr()\fR
121performs a reverse lookup
122of address
123\fIsrc\fR
124which is
125\fIlen\fR
126bytes long.
127\fIaf\fR
128denotes the protocol family, typically
129\fBPF_INET\fR
130or
131\fBPF_INET6\fR.
132.PP
133\fBlwres_freehostent()\fR
134releases all the memory associated with
135the
136\fBstruct hostent\fR
137pointer
138\fIhe\fR.
139Any memory allocated for the
140h_name,
141h_addr_list
142and
143h_aliases
144is freed, as is the memory for the
145\fBhostent\fR
146structure itself.
147.SH "RETURN VALUES"
148.PP
149If an error occurs,
150\fBlwres_getipnodebyname()\fR
151and
152\fBlwres_getipnodebyaddr()\fR
153set
154\fI*error_num\fR
155to an approriate error code and the function returns a
156\fBNULL\fR
157pointer.
158The error codes and their meanings are defined in
159\fI<lwres/netdb.h>\fR:
160.TP
161\fBHOST_NOT_FOUND\fR
162No such host is known.
163.TP
164\fBNO_ADDRESS\fR
165The server recognised the request and the name but no address is
166available. Another type of request to the name server for the
167domain might return an answer.
168.TP
169\fBTRY_AGAIN\fR
170A temporary and possibly transient error occurred, such as a
171failure of a server to respond. The request may succeed if
172retried.
173.TP
174\fBNO_RECOVERY\fR
175An unexpected failure occurred, and retrying the request
176is pointless.
177.PP
178\fBlwres_hstrerror\fR(3)
179translates these error codes to suitable error messages.
180.SH "SEE ALSO"
181.PP
182\fBRFC2553\fR,
183\fBlwres\fR(3),
184\fBlwres_gethostent\fR(3),
185\fBlwres_getaddrinfo\fR(3),
186\fBlwres_getnameinfo\fR(3),
187\fBlwres_hstrerror\fR(3).