1GETIPNODEBYNAME(3)         Linux Programmer's Manual        GETIPNODEBYNAME(3)
2
3
4

NAME

6       getipnodebyname,  getipnodebyaddr,  freehostent - get network hostnames
7       and addresses
8

SYNOPSIS

10       #include <sys/types.h>
11       #include <sys/socket.h>
12       #include <netdb.h>
13
14       struct hostent *getipnodebyname(const char *name, int af,
15                                       int flags, int *error_num);
16       struct hostent *getipnodebyaddr(const void *addr, size_t len,
17                                       int af, int *error_num);
18       void freehostent(struct hostent *ip);
19

DESCRIPTION

21       These functions are deprecated (and unavailable in glibc).  Use  getad‐
22       drinfo(3) and getnameinfo(3) instead.
23
24       The  getipnodebyname() and getipnodebyaddr() functions return the names
25       and addresses of a network host.  These functions return a  pointer  to
26       the following structure:
27
28           struct hostent {
29               char  *h_name;
30               char **h_aliases;
31               int    h_addrtype;
32               int    h_length;
33               char **h_addr_list;
34           };
35
36       These functions replace the gethostbyname(3) and gethostbyaddr(3) func‐
37       tions, which could access only the IPv4 network  address  family.   The
38       getipnodebyname()  and  getipnodebyaddr() functions can access multiple
39       network address families.
40
41       Unlike the gethostby functions, these functions return pointers to  dy‐
42       namically  allocated memory.  The freehostent() function is used to re‐
43       lease the dynamically allocated memory after the caller no longer needs
44       the hostent structure.
45
46   getipnodebyname() arguments
47       The  getipnodebyname() function looks up network addresses for the host
48       specified by the name argument.  The af argument specifies one  of  the
49       following values:
50
51       AF_INET
52              The name argument points to a dotted-quad IPv4 address or a name
53              of an IPv4 network host.
54
55       AF_INET6
56              The name argument points to a hexadecimal IPv6 address or a name
57              of an IPv6 network host.
58
59       The  flags argument specifies additional options.  More than one option
60       can be specified by bitwise OR-ing them together.  flags should be  set
61       to 0 if no options are desired.
62
63       AI_V4MAPPED
64              This  flag is used with AF_INET6 to request a query for IPv4 ad‐
65              dresses instead of IPv6 addresses; the IPv4  addresses  will  be
66              mapped to IPv6 addresses.
67
68       AI_ALL This  flag  is used with AI_V4MAPPED to request a query for both
69              IPv4 and IPv6 addresses.  Any IPv4 address found will be  mapped
70              to an IPv6 address.
71
72       AI_ADDRCONFIG
73              This  flag is used with AF_INET6 to further request that queries
74              for IPv6 addresses should not be made unless the system  has  at
75              least one IPv6 address assigned to a network interface, and that
76              queries for IPv4 addresses should not be made unless the  system
77              has  at  least one IPv4 address assigned to a network interface.
78              This flag may be used by itself or with the AI_V4MAPPED flag.
79
80       AI_DEFAULT
81              This flag is equivalent to (AI_ADDRCONFIG | AI_V4MAPPED).
82
83   getipnodebyaddr() arguments
84       The getipnodebyaddr() function looks up the name of the host whose net‐
85       work address is specified by the addr argument.  The af argument speci‐
86       fies one of the following values:
87
88       AF_INET
89              The addr argument points to a struct in_addr and len must be set
90              to sizeof(struct in_addr).
91
92       AF_INET6
93              The  addr  argument  points to a struct in6_addr and len must be
94              set to sizeof(struct in6_addr).
95

RETURN VALUE

97       NULL is returned if an error occurred, and error_num  will  contain  an
98       error code from the following list:
99
100       HOST_NOT_FOUND
101              The hostname or network address was not found.
102
103       NO_ADDRESS
104              The  domain  name server recognized the network address or name,
105              but no answer was returned.  This can happen if the network host
106              has only IPv4 addresses and a request has been made for IPv6 in‐
107              formation only, or vice versa.
108
109       NO_RECOVERY
110              The domain name server returned a permanent failure response.
111
112       TRY_AGAIN
113              The domain name server returned a  temporary  failure  response.
114              You might have better luck next time.
115
116       A  successful  query returns a pointer to a hostent structure that con‐
117       tains the following fields:
118
119       h_name This is the official name of this network host.
120
121       h_aliases
122              This is an array of pointers to unofficial aliases for the  same
123              host.  The array is terminated by a null pointer.
124
125       h_addrtype
126              This  is  a  copy  of  the  af  argument to getipnodebyname() or
127              getipnodebyaddr().  h_addrtype will always be AF_INET if the  af
128              argument was AF_INET.  h_addrtype will always be AF_INET6 if the
129              af argument was AF_INET6.
130
131       h_length
132              This field will be set to sizeof(struct in_addr)  if  h_addrtype
133              is  AF_INET,  and  to  sizeof(struct  in6_addr) if h_addrtype is
134              AF_INET6.
135
136       h_addr_list
137              This is an array of one or  more  pointers  to  network  address
138              structures  for  the network host.  The array is terminated by a
139              null pointer.
140

CONFORMING TO

142       RFC 2553.
143

NOTES

145       These functions were present  in  glibc  2.1.91-95,  but  were  removed
146       again.   Several UNIX-like systems support them, but all call them dep‐
147       recated.
148

SEE ALSO

150       getaddrinfo(3), getnameinfo(3), inet_ntop(3), inet_pton(3)
151

COLOPHON

153       This page is part of release 5.13 of the Linux  man-pages  project.   A
154       description  of  the project, information about reporting bugs, and the
155       latest    version    of    this    page,    can     be     found     at
156       https://www.kernel.org/doc/man-pages/.
157
158
159
160Linux                             2021-03-22                GETIPNODEBYNAME(3)
Impressum