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