📄 lwres_getipnode.3
字号:
.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC").\" Copyright (C) 2000, 2001 Internet Software Consortium..\".\" Permission to use, copy, modify, and distribute this software for any.\" purpose with or without fee is hereby granted, provided that the above.\" copyright notice and this permission notice appear in all copies..\".\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH.\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY.\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM.\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR.\" PERFORMANCE OF THIS SOFTWARE..\".\" $Id: lwres_getipnode.3,v 1.13.2.2.4.2 2004/03/09 05:21:10 marka Exp $.\".TH "LWRES_GETIPNODE" "3" "Jun 30, 2000" "BIND9" "".SH NAMElwres_getipnodebyname, lwres_getipnodebyaddr, lwres_freehostent \- lightweight resolver nodename / address translation API.SH SYNOPSIS\fB#include <lwres/netdb.h>.sp.nastruct hostent *lwres_getipnodebyname(const char *name, int af, int flags, int *error_num);.ad.sp.nastruct hostent *lwres_getipnodebyaddr(const void *src, size_t len, int af, int *error_num);.ad.sp.navoidlwres_freehostent(struct hostent *he);.ad\fR.SH "DESCRIPTION".PPThese functions perform thread safe, protocol independentnodename-to-address and address-to-nodename translation as defined in RFC2553..PPThey use a\fBstruct hostent\fRwhich is defined in\fInamedb.h\fR:.sp.nfstruct hostent { char *h_name; /* official name of host */ char **h_aliases; /* alias list */ int h_addrtype; /* host address type */ int h_length; /* length of address */ char **h_addr_list; /* list of addresses from name server */};#define h_addr h_addr_list[0] /* address, for backward compatibility */.sp.fi.PPThe members of this structure are:.TP\fBh_name\fRThe official (canonical) name of the host..TP\fBh_aliases\fRA NULL-terminated array of alternate names (nicknames) for the host..TP\fBh_addrtype\fRThe type of address being returned - usually\fBPF_INET\fRor\fBPF_INET6\fR..TP\fBh_length\fRThe length of the address in bytes..TP\fBh_addr_list\fRA\fBNULL\fRterminated array of network addresses for the host.Host addresses are returned in network byte order..PP\fBlwres_getipnodebyname()\fRlooks up addresses of protocol family\fIaf\fRfor the hostname\fIname\fR.The\fIflags\fRparameter contains ORed flag bits to specify the types of addresses that are searchedfor, and the types of addresses that are returned. The flag bits are:.TP\fBAI_V4MAPPED\fRThis is used with an\fIaf\fRof AF_INET6, and causes IPv4 addresses to be returned as IPv4-mappedIPv6 addresses..TP\fBAI_ALL\fRThis is used with an\fIaf\fRof AF_INET6, and causes all known addresses (IPv6 and IPv4) to be returned.If AI_V4MAPPED is also set, the IPv4 addresses are return as mappedIPv6 addresses..TP\fBAI_ADDRCONFIG\fROnly return an IPv6 or IPv4 address if here is an active networkinterface of that type. This is not currently implementedin the BIND 9 lightweight resolver, and the flag is ignored..TP\fBAI_DEFAULT\fRThis default sets theAI_V4MAPPEDandAI_ADDRCONFIGflag bits..PP\fBlwres_getipnodebyaddr()\fRperforms a reverse lookupof address\fIsrc\fRwhich is\fIlen\fRbytes long.\fIaf\fRdenotes the protocol family, typically\fBPF_INET\fRor\fBPF_INET6\fR..PP\fBlwres_freehostent()\fRreleases all the memory associated withthe\fBstruct hostent\fRpointer\fIhe\fR.Any memory allocated for theh_name,h_addr_listandh_aliasesis freed, as is the memory for the\fBhostent\fRstructure itself..SH "RETURN VALUES".PPIf an error occurs,\fBlwres_getipnodebyname()\fRand\fBlwres_getipnodebyaddr()\fRset\fI*error_num\fRto an appropriate error code and the function returns a\fBNULL\fRpointer.The error codes and their meanings are defined in\fI<lwres/netdb.h>\fR:.TP\fBHOST_NOT_FOUND\fRNo such host is known..TP\fBNO_ADDRESS\fRThe server recognised the request and the name but no address isavailable. Another type of request to the name server for thedomain might return an answer..TP\fBTRY_AGAIN\fRA temporary and possibly transient error occurred, such as afailure of a server to respond. The request may succeed ifretried..TP\fBNO_RECOVERY\fRAn unexpected failure occurred, and retrying the requestis pointless..PP\fBlwres_hstrerror\fR(3)translates these error codes to suitable error messages..SH "SEE ALSO".PP\fBRFC2553\fR,\fBlwres\fR(3),\fBlwres_gethostent\fR(3),\fBlwres_getaddrinfo\fR(3),\fBlwres_getnameinfo\fR(3),\fBlwres_hstrerror\fR(3).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -