1LWRES_GETIPNODE(3) BIND9 LWRES_GETIPNODE(3)
2
3
4
6 lwres_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent -
7 lightweight resolver nodename / address translation API
8
10 #include <lwres/netdb.h>
11
12 struct hostent * lwres_getipnodebyname(const char *name, int af,
13 int flags, int *error_num);
14
15 struct hostent * lwres_getipnodebyaddr(const void *src, size_t len,
16 int af, int *error_num);
17
18 void lwres_freehostent(struct hostent *he);
19
21 These functions perform thread safe, protocol independent
22 nodename-to-address and address-to-nodename translation as defined in
23 RFC2553.
24
25 They use a struct hostent which is defined in namedb.h:
26
27 struct hostent {
28 char *h_name; /* official name of host */
29 char **h_aliases; /* alias list */
30 int h_addrtype; /* host address type */
31 int h_length; /* length of address */
32 char **h_addr_list; /* list of addresses from name server */
33 };
34 #define h_addr h_addr_list[0] /* address, for backward compatibility */
35
36 The members of this structure are:
37
38 h_name
39 The official (canonical) name of the host.
40
41 h_aliases
42 A NULL-terminated array of alternate names (nicknames) for the
43 host.
44
45 h_addrtype
46 The type of address being returned - usually PF_INET or PF_INET6.
47
48 h_length
49 The length of the address in bytes.
50
51 h_addr_list
52 A NULL terminated array of network addresses for the host. Host
53 addresses are returned in network byte order.
54
55 lwres_getipnodebyname() looks up addresses of protocol family af for
56 the hostname name. The flags parameter contains ORed flag bits to
57 specify the types of addresses that are searched for, and the types of
58 addresses that are returned. The flag bits are:
59
60 AI_V4MAPPED
61 This is used with an af of AF_INET6, and causes IPv4 addresses to
62 be returned as IPv4-mapped IPv6 addresses.
63
64 AI_ALL
65 This is used with an af of AF_INET6, and causes all known addresses
66 (IPv6 and IPv4) to be returned. If AI_V4MAPPED is also set, the
67 IPv4 addresses are return as mapped IPv6 addresses.
68
69 AI_ADDRCONFIG
70 Only return an IPv6 or IPv4 address if here is an active network
71 interface of that type. This is not currently implemented in the
72 BIND 9 lightweight resolver, and the flag is ignored.
73
74 AI_DEFAULT
75 This default sets the AI_V4MAPPED and AI_ADDRCONFIG flag bits.
76
77 lwres_getipnodebyaddr() performs a reverse lookup of address src which
78 is len bytes long. af denotes the protocol family, typically PF_INET
79 or PF_INET6.
80
81 lwres_freehostent() releases all the memory associated with the struct
82 hostent pointer he. Any memory allocated for the h_name, h_addr_list
83 and h_aliases is freed, as is the memory for the hostent structure
84 itself.
85
87 If an error occurs, lwres_getipnodebyname() and lwres_getipnodebyaddr()
88 set *error_num to an appropriate error code and the function returns a
89 NULL pointer. The error codes and their meanings are defined in
90 <lwres/netdb.h>:
91
92 HOST_NOT_FOUND
93 No such host is known.
94
95 NO_ADDRESS
96 The server recognised the request and the name but no address is
97 available. Another type of request to the name server for the
98 domain might return an answer.
99
100 TRY_AGAIN
101 A temporary and possibly transient error occurred, such as a
102 failure of a server to respond. The request may succeed if retried.
103
104 NO_RECOVERY
105 An unexpected failure occurred, and retrying the request is
106 pointless.
107
108 lwres_hstrerror(3) translates these error codes to suitable error
109 messages.
110
112 RFC2553(), lwres(3), lwres_gethostent(3), lwres_getaddrinfo(3),
113 lwres_getnameinfo(3), lwres_hstrerror(3).
114
116 Internet Systems Consortium, Inc.
117
119 Copyright © 2000, 2001, 2003-2005, 2007, 2014-2016, 2018-2020 Internet
120 Systems Consortium, Inc. ("ISC")
121
122
123
124ISC 2007-06-18 LWRES_GETIPNODE(3)