jpayne@68: .\" jpayne@68: .\" Copyright 2005 by Dominick Meglio. jpayne@68: .\" SPDX-License-Identifier: MIT jpayne@68: .\" jpayne@68: .TH ARES_GETNAMEINFO 3 "1 May 2009" jpayne@68: .SH NAME jpayne@68: ares_getnameinfo \- Address-to-nodename translation in protocol-independent manner jpayne@68: .SH SYNOPSIS jpayne@68: .nf jpayne@68: #include jpayne@68: jpayne@68: typedef void (*ares_nameinfo_callback)(void *\fIarg\fP, int \fIstatus\fP, jpayne@68: int \fItimeouts\fP, char *\fInode\fP, jpayne@68: char *\fIservice\fP) jpayne@68: jpayne@68: void ares_getnameinfo(ares_channel_t *\fIchannel\fP, const struct sockaddr *\fIsa\fP, jpayne@68: ares_socklen_t \fIsalen\fP, int \fIflags\fP, jpayne@68: ares_nameinfo_callback \fIcallback\fP, void *\fIarg\fP) jpayne@68: .fi jpayne@68: .SH DESCRIPTION jpayne@68: The jpayne@68: .B ares_getnameinfo jpayne@68: function is defined for protocol-independent address translation. The function jpayne@68: is a combination of \fIares_gethostbyaddr(3)\fP and \fIgetservbyport(3)\fP. The function will jpayne@68: translate the address either by executing a host query on the name service channel jpayne@68: identified by jpayne@68: .IR channel jpayne@68: or it will attempt to resolve it locally if possible. jpayne@68: The parameters jpayne@68: .I sa jpayne@68: and jpayne@68: .I len jpayne@68: give the address as a sockaddr structure, and jpayne@68: .I flags jpayne@68: gives the options that the function will use. Valid flags are listed below: jpayne@68: .TP 19 jpayne@68: .B ARES_NI_NOFQDN jpayne@68: Only the nodename portion of the FQDN is returned for local hosts. jpayne@68: .TP 19 jpayne@68: .B ARES_NI_NUMERICHOST jpayne@68: The numeric form of the hostname is returned rather than the name. jpayne@68: .TP 19 jpayne@68: .B ARES_NI_NAMEREQD jpayne@68: An error is returned if the hostname cannot be found in the DNS. jpayne@68: .TP 19 jpayne@68: .B ARES_NI_NUMERICSERV jpayne@68: The numeric form of the service is returned rather than the name. jpayne@68: .TP 19 jpayne@68: .B ARES_NI_TCP jpayne@68: The service name is to be looked up for the TCP protocol. jpayne@68: .TP 19 jpayne@68: .B ARES_NI_UDP jpayne@68: The service name is to be looked up for the UDP protocol. jpayne@68: .TP 19 jpayne@68: .B ARES_NI_SCTP jpayne@68: The service name is to be looked up for the SCTP protocol. jpayne@68: .TP 19 jpayne@68: .B ARES_NI_DCCP jpayne@68: The service name is to be looked up for the DCCP protocol. jpayne@68: .TP 19 jpayne@68: .B ARES_NI_NUMERICSCOPE jpayne@68: The numeric form of the scope ID is returned rather than the name. jpayne@68: .TP 19 jpayne@68: .B ARES_NI_LOOKUPHOST jpayne@68: A hostname lookup is being requested. jpayne@68: .TP 19 jpayne@68: .B ARES_NI_LOOKUPSERVICE jpayne@68: A service name lookup is being requested. jpayne@68: .PP jpayne@68: When the query jpayne@68: is complete or has jpayne@68: failed, the ares library will invoke \fIcallback\fP. Completion or failure of jpayne@68: the query may happen immediately, or may happen during a later call to jpayne@68: \fIares_process(3)\fP, \fIares_destroy(3)\fP or \fIares_cancel(3)\fP. jpayne@68: .PP jpayne@68: When the associated callback is called, it is called with a channel lock so care jpayne@68: must be taken to ensure any processing is minimal to prevent DNS channel stalls. jpayne@68: jpayne@68: The callback may be triggered from a different thread than the one which jpayne@68: called \fIares_getnameinfo(3)\fP. jpayne@68: jpayne@68: For integrators running their own event loops and not using \fBARES_OPT_EVENT_THREAD\fP, jpayne@68: care needs to be taken to ensure any file descriptor lists are updated immediately jpayne@68: within the eventloop when notified. jpayne@68: .PP jpayne@68: The callback argument jpayne@68: .I arg jpayne@68: is copied from the jpayne@68: .B ares_getnameinfo jpayne@68: argument jpayne@68: .IR arg . jpayne@68: The callback argument jpayne@68: .I status jpayne@68: indicates whether the query succeeded and, if not, how it failed. It jpayne@68: may have any of the following values: jpayne@68: .TP 19 jpayne@68: .B ARES_SUCCESS jpayne@68: The host lookup completed successfully. jpayne@68: .TP 19 jpayne@68: .B ARES_ENOTIMP jpayne@68: The ares library does not know how to look up addresses of type jpayne@68: .IR family . jpayne@68: .TP 19 jpayne@68: .B ARES_ENOTFOUND jpayne@68: The address jpayne@68: .I addr jpayne@68: was not found. jpayne@68: .TP 19 jpayne@68: .B ARES_ENOMEM jpayne@68: Memory was exhausted. jpayne@68: .TP 19 jpayne@68: .B ARES_ECANCELLED jpayne@68: The query was cancelled. jpayne@68: .TP 19 jpayne@68: .B ARES_EDESTRUCTION jpayne@68: The name service channel jpayne@68: .I channel jpayne@68: is being destroyed; the query will not be completed. jpayne@68: .TP 19 jpayne@68: .B ARES_EBADFLAGS jpayne@68: The jpayne@68: .I flags jpayne@68: parameter contains an illegal value. jpayne@68: .PP jpayne@68: The callback argument jpayne@68: .I timeouts jpayne@68: reports how many times a query timed out during the execution of the jpayne@68: given request. jpayne@68: .PP jpayne@68: On successful completion of the query, the callback argument jpayne@68: .I node jpayne@68: contains a string representing the hostname (assuming jpayne@68: .B ARES_NI_LOOKUPHOST jpayne@68: was specified). Additionally, jpayne@68: .I service jpayne@68: contains a string representing the service name (assuming jpayne@68: .B ARES_NI_LOOKUPSERVICE jpayne@68: was specified). jpayne@68: If the query did not complete successfully, or one of the values jpayne@68: was not requested, jpayne@68: .I node jpayne@68: or jpayne@68: .I service jpayne@68: will be jpayne@68: .BR NULL . jpayne@68: .SH SEE ALSO jpayne@68: .BR ares_process (3),