Blame ares_getnameinfo.3

Packit 514978
.\"
Packit 514978
.\" Copyright 2005 by Dominick Meglio.
Packit 514978
.\"
Packit 514978
.\" Permission to use, copy, modify, and distribute this
Packit 514978
.\" software and its documentation for any purpose and without
Packit 514978
.\" fee is hereby granted, provided that the above copyright
Packit 514978
.\" notice appear in all copies and that both that copyright
Packit 514978
.\" notice and this permission notice appear in supporting
Packit 514978
.\" documentation, and that the name of M.I.T. not be used in
Packit 514978
.\" advertising or publicity pertaining to distribution of the
Packit 514978
.\" software without specific, written prior permission.
Packit 514978
.\" M.I.T. makes no representations about the suitability of
Packit 514978
.\" this software for any purpose.  It is provided "as is"
Packit 514978
.\" without express or implied warranty.
Packit 514978
.\"
Packit 514978
.TH ARES_GETNAMEINFO 3 "1 May 2009"
Packit 514978
.SH NAME
Packit 514978
ares_getnameinfo \- Address-to-nodename translation in protocol-independent manner
Packit 514978
.SH SYNOPSIS
Packit 514978
.nf
Packit 514978
.B #include <ares.h>
Packit 514978
.PP
Packit 514978
.B typedef void (*ares_nameinfo_callback)(void *\fIarg\fP, int \fIstatus\fP,
Packit 514978
.B	int \fItimeouts\fP, char *\fInode\fP, char *\fIservice\fP)
Packit 514978
.PP
Packit 514978
.B void ares_getnameinfo(ares_channel \fIchannel\fP, const struct sockaddr *\fIsa\fP,
Packit 514978
.B 	ares_socklen_t \fIsalen\fP, int \fIflags\fP, ares_nameinfo_callback \fIcallback\fP,
Packit 514978
.B 	void *\fIarg\fP)
Packit 514978
.fi
Packit 514978
.SH DESCRIPTION
Packit 514978
The
Packit 514978
.B ares_getnameinfo
Packit 514978
function is defined for protocol-independent address translation. The function
Packit 514978
is a combination of \fIares_gethostbyaddr(3)\fP and \fIgetservbyport(3)\fP. The function will
Packit 514978
translate the address either by executing a host query on the name service channel
Packit 514978
identified by
Packit 514978
.IR channel 
Packit 514978
or it will attempt to resolve it locally if possible.
Packit 514978
The parameters
Packit 514978
.I sa
Packit 514978
and
Packit 514978
.I len
Packit 514978
give the address as a sockaddr structure, and
Packit 514978
.I flags
Packit 514978
gives the options that the function will use.  Valid flags are listed below:
Packit 514978
.TP 19
Packit 514978
.B ARES_NI_NOFQDN
Packit 514978
Only the nodename portion of the FQDN is returned for local hosts.
Packit 514978
.TP 19
Packit 514978
.B ARES_NI_NUMERICHOST
Packit 514978
The numeric form of the hostname is returned rather than the name.
Packit 514978
.TP 19
Packit 514978
.B ARES_NI_NAMEREQD
Packit 514978
An error is returned if the hostname cannot be found in the DNS.
Packit 514978
.TP 19
Packit 514978
.B ARES_NI_NUMERICSERV
Packit 514978
The numeric form of the service is returned rather than the name.
Packit 514978
.TP 19
Packit 514978
.B ARES_NI_TCP
Packit 514978
The service name is to be looked up for the TCP protocol.
Packit 514978
.TP 19
Packit 514978
.B ARES_NI_UDP
Packit 514978
The service name is to be looked up for the UDP protocol.
Packit 514978
.TP 19
Packit 514978
.B ARES_NI_SCTP
Packit 514978
The service name is to be looked up for the SCTP protocol.
Packit 514978
.TP 19
Packit 514978
.B ARES_NI_DCCP
Packit 514978
The service name is to be looked up for the DCCP protocol.
Packit 514978
.TP 19
Packit 514978
.B ARES_NI_NUMERICSCOPE
Packit 514978
The numeric form of the scope ID is returned rather than the name.
Packit 514978
.TP 19
Packit 514978
.B ARES_NI_LOOKUPHOST
Packit 514978
A hostname lookup is being requested.
Packit 514978
.TP 19
Packit 514978
.B ARES_NI_LOOKUPSERVICE
Packit 514978
A service name lookup is being requested.
Packit 514978
.PP
Packit 514978
When the query
Packit 514978
is complete or has 
Packit 514978
failed, the ares library will invoke \fIcallback\fP.  Completion or failure of 
Packit 514978
the query may happen immediately, or may happen during a later call to
Packit 514978
\fIares_process(3)\fP, \fIares_destroy(3)\fP or \fIares_cancel(3)\fP.
Packit 514978
.PP
Packit 514978
The callback argument
Packit 514978
.I arg
Packit 514978
is copied from the
Packit 514978
.B ares_getnameinfo
Packit 514978
argument
Packit 514978
.IR arg .
Packit 514978
The callback argument
Packit 514978
.I status
Packit 514978
indicates whether the query succeeded and, if not, how it failed.  It
Packit 514978
may have any of the following values:
Packit 514978
.TP 19
Packit 514978
.B ARES_SUCCESS
Packit 514978
The host lookup completed successfully.
Packit 514978
.TP 19
Packit 514978
.B ARES_ENOTIMP
Packit 514978
The ares library does not know how to look up addresses of type
Packit 514978
.IR family .
Packit 514978
.TP 19
Packit 514978
.B ARES_ENOTFOUND
Packit 514978
The address
Packit 514978
.I addr
Packit 514978
was not found.
Packit 514978
.TP 19
Packit 514978
.B ARES_ENOMEM
Packit 514978
Memory was exhausted.
Packit 514978
.TP 19
Packit 514978
.B ARES_ECANCELLED
Packit 514978
The query was cancelled.
Packit 514978
.TP 19
Packit 514978
.B ARES_EDESTRUCTION
Packit 514978
The name service channel
Packit 514978
.I channel
Packit 514978
is being destroyed; the query will not be completed.
Packit 514978
.TP 19
Packit 514978
.B ARES_EBADFLAGS
Packit 514978
The
Packit 514978
.I flags
Packit 514978
parameter contains an illegal value.
Packit 514978
.PP
Packit 514978
The callback argument
Packit 514978
.I timeouts
Packit 514978
reports how many times a query timed out during the execution of the
Packit 514978
given request.
Packit 514978
.PP
Packit 514978
On successful completion of the query, the callback argument
Packit 514978
.I node
Packit 514978
contains a string representing the hostname (assuming 
Packit 514978
.B ARES_NI_LOOKUPHOST
Packit 514978
was specified). Additionally, 
Packit 514978
.I service
Packit 514978
contains a string representing the service name (assuming
Packit 514978
.B ARES_NI_LOOKUPSERVICE
Packit 514978
was specified).
Packit 514978
If the query did not complete successfully, or one of the values
Packit 514978
was not requested, 
Packit 514978
.I node
Packit 514978
or
Packit 514978
.I service
Packit 514978
will be 
Packit 514978
.BR NULL .
Packit 514978
.SH SEE ALSO
Packit 514978
.BR ares_process (3),
Packit 514978
.SH AUTHOR
Packit 514978
Dominick Meglio
Packit 514978
.br
Packit 514978
Copyright 2005 by Dominick Meglio.