]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/getipnodebyname.3
libc.7: Add a note on why glibc 2.x uses the soname libc.so.6
[thirdparty/man-pages.git] / man3 / getipnodebyname.3
CommitLineData
fea681da
MK
1.\" Copyright 2000 Sam Varshavchik <mrsam@courier-mta.com>
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
24.\"
25.\" References: RFC 2553
72542487 26.TH GETIPNODEBYNAME 3 2010-09-04 "Linux" "Linux Programmer's Manual"
fea681da 27.SH NAME
c13182ef 28getipnodebyname, getipnodebyaddr, freehostent \- get network
ddaec46d 29hostnames and addresses
fea681da
MK
30.SH SYNOPSIS
31.nf
32.B #include <sys/types.h>
33.B #include <sys/socket.h>
34.B #include <netdb.h>
35.sp
62218dc0
MK
36.BI "struct hostent *getipnodebyname(const char *" name ", int " af ,
37.BI " int " flags ", int *" error_num );
fea681da 38.sp
62218dc0 39.BI "struct hostent *getipnodebyaddr(const void *" addr ", size_t " len ,
eaa88fd8 40.BI " int " af ", int *" "error_num" );
fea681da
MK
41.sp
42.BI "void freehostent(struct hostent *" "ip" );
43.fi
44.SH DESCRIPTION
a5b9e015 45These functions are deprecated (and unavailable in glibc).
c13182ef 46Use
fea681da
MK
47.BR getaddrinfo (3)
48and
49.BR getnameinfo (3)
50instead.
51.LP
52The
2777b1ca 53.BR getipnodebyname ()
fea681da 54and
2777b1ca 55.BR getipnodebyaddr ()
fea681da
MK
56functions return the names and addresses of a network host.
57These functions return a pointer to the
58following structure:
59.sp
3ad4ddcd 60.in +4n
fea681da 61.nf
4e836144 62struct hostent {
89f9f5b2
MK
63 char *h_name;
64 char **h_aliases;
65 int h_addrtype;
66 int h_length;
67 char **h_addr_list;
cf50b31d 68};
3ad4ddcd 69.in
fea681da
MK
70.fi
71.PP
72These functions replace the
73.BR gethostbyname (3)
74and
75.BR gethostbyaddr (3)
33a0ccb2 76functions, which could access only the IPv4 network address family.
fea681da 77The
2777b1ca 78.BR getipnodebyname ()
fea681da 79and
2777b1ca 80.BR getipnodebyaddr ()
fea681da
MK
81functions can access multiple network address families.
82.PP
83Unlike the
84.B gethostby
85functions,
f19a0f03 86these functions return pointers to dynamically allocated memory.
fea681da 87The
2777b1ca 88.BR freehostent ()
fea681da
MK
89function is used to release the dynamically allocated memory
90after the caller no longer needs the
11003586 91.I hostent
fea681da 92structure.
c4bb193f 93.SS getipnodebyname() arguments
fea681da 94The
2777b1ca 95.BR getipnodebyname ()
fea681da
MK
96function
97looks up network addresses for the host
98specified by the
99.I name
c4bb193f 100argument.
fea681da
MK
101The
102.I af
c4bb193f 103argument specifies one of the following values:
fea681da
MK
104.TP
105.B AF_INET
106The
107.I name
c4bb193f 108argument points to a dotted-quad IPv4 address or a name
fea681da
MK
109of an IPv4 network host.
110.TP
111.B AF_INET6
112The
113.I name
c4bb193f 114argument points to a hexadecimal IPv6 address or a name
fea681da
MK
115of an IPv6 network host.
116.PP
117The
118.I flags
c4bb193f 119argument specifies additional options.
b7d6564b 120More than one option can be specified by bitwise OR-ing
fea681da
MK
121them together.
122.I flags
123should be set to 0
124if no options are desired.
125.TP
126.B AI_V4MAPPED
127This flag is used with
128.B AF_INET6
129to request a query for IPv4 addresses instead of
130IPv6 addresses; the IPv4 addresses will
131be mapped to IPv6 addresses.
132.TP
133.B AI_ALL
134This flag is used with
135.B AI_V4MAPPED
136to request a query for both IPv4 and IPv6 addresses.
137Any IPv4 address found will be mapped to an IPv6 address.
138.TP
139.B AI_ADDRCONFIG
140This flag is used with
141.B AF_INET6
142to
143further request that queries for IPv6 addresses should not be made unless
144the system has at least one IPv6 address assigned to a network interface,
145and that queries for IPv4 addresses should not be made unless the
146system has at least one IPv4 address assigned to a network interface.
147This flag may be used by itself or with the
148.B AI_V4MAPPED
149flag.
150.TP
151.B AI_DEFAULT
c13182ef 152This flag is equivalent to
fea681da 153.BR "(AI_ADDRCONFIG | AI_V4MAPPED)" .
c4bb193f 154.SS getipnodebyaddr() arguments
fea681da 155The
2777b1ca 156.BR getipnodebyaddr ()
fea681da
MK
157function
158looks up the name of the host whose
159network address is
160specified by the
161.I addr
c4bb193f 162argument.
fea681da
MK
163The
164.I af
c4bb193f 165argument specifies one of the following values:
fea681da
MK
166.TP
167.B AF_INET
168The
169.I addr
c4bb193f 170argument points to a
8478ee02 171.I struct in_addr
fea681da
MK
172and
173.I len
174must be set to
8478ee02 175.IR "sizeof(struct in_addr)" .
fea681da
MK
176.TP
177.B AF_INET6
178The
179.I addr
c4bb193f 180argument points to a
8478ee02 181.I struct in6_addr
fea681da
MK
182and
183.I len
184must be set to
8478ee02 185.IR "sizeof(struct in6_addr)" .
47297adb 186.SH RETURN VALUE
b437fdd9 187NULL is returned if an error occurred, and
fea681da
MK
188.I error_num
189will contain an error code from the following list:
190.TP
191.B HOST_NOT_FOUND
ddaec46d 192The hostname or network address was not found.
fea681da
MK
193.TP
194.B NO_ADDRESS
195The domain name server recognized the network address or name,
196but no answer was returned.
197This can happen if the network host has only IPv4 addresses and
198a request has been made for IPv6 information only, or vice versa.
199.TP
200.B NO_RECOVERY
201The domain name server returned a permanent failure response.
202.TP
203.B TRY_AGAIN
204The domain name server returned a temporary failure response.
205You might have better luck next time.
206.PP
207A successful query returns a pointer to a
11003586 208.I hostent
fea681da
MK
209structure that contains the following fields:
210.TP
11003586 211.I h_name
fea681da
MK
212This is the official name of this network host.
213.TP
11003586 214.I h_aliases
fea681da 215This is an array of pointers to unofficial aliases for the same host.
b437fdd9 216The array is terminated by a null pointer.
fea681da 217.TP
11003586 218.I h_addrtype
fea681da
MK
219This is a copy of the
220.I af
c4bb193f 221argument to
2777b1ca 222.BR getipnodebyname ()
fea681da 223or
2777b1ca 224.BR getipnodebyaddr ().
fea681da
MK
225.I h_addrtype
226will always be
227.B AF_INET
228if the
229.I af
c4bb193f 230argument was
fea681da
MK
231.BR AF_INET .
232.I h_addrtype
233will always be
234.B AF_INET6
235if the
236.I af
c4bb193f 237argument was
fea681da
MK
238.BR AF_INET6 .
239.TP
11003586 240.I h_length
fea681da 241This field will be set to
8478ee02 242.I sizeof(struct in_addr)
fea681da
MK
243if
244.I h_addrtype
2f0af33b
MK
245is
246.BR AF_INET ,
247and to
8478ee02 248.I sizeof(struct in6_addr)
fea681da
MK
249if
250.I h_addrtype
2f0af33b
MK
251is
252.BR AF_INET6 .
fea681da 253.TP
11003586 254.I h_addr_list
fea681da
MK
255This is an array of one or more pointers to network address structures for the
256network host.
b437fdd9 257The array is terminated by a null pointer.
47297adb 258.SH CONFORMING TO
2b2581ee
MK
259RFC\ 2553.
260.\" Not in POSIX.1-2001.
fea681da 261.SH NOTES
881f6c4a 262These functions were present in glibc 2.1.91-95, but were
c13182ef 263removed again.
008f1ecc 264Several UNIX-like systems support them, but all
fea681da 265call them deprecated.
47297adb 266.SH SEE ALSO
fea681da
MK
267.BR getaddrinfo (3),
268.BR getnameinfo (3),
269.BR inet_ntop (3),
270.BR inet_pton (3)