Blame ares_query.3

Packit 514978
.\"
Packit 514978
.\" Copyright 1998 by the Massachusetts Institute of Technology.
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_QUERY 3 "24 July 1998"
Packit 514978
.SH NAME
Packit 514978
ares_query \- Initiate a single-question DNS query
Packit 514978
.SH SYNOPSIS
Packit 514978
.nf
Packit 514978
.B #include <ares.h>
Packit 514978
.PP
Packit 514978
.B typedef void (*ares_callback)(void *\fIarg\fP, int \fIstatus\fP,
Packit 514978
.B	int \fItimeouts\fP, unsigned char *\fIabuf\fP, int \fIalen\fP)
Packit 514978
.PP
Packit 514978
.B void ares_query(ares_channel \fIchannel\fP, const char *\fIname\fP,
Packit 514978
.B 	int \fIdnsclass\fP, int \fItype\fP, ares_callback \fIcallback\fP,
Packit 514978
.B	void *\fIarg\fP)
Packit 514978
.fi
Packit 514978
.SH DESCRIPTION
Packit 514978
The
Packit 514978
.B ares_query
Packit 514978
function initiates a single-question DNS query on the name service
Packit 514978
channel identified by
Packit 514978
.IR channel .
Packit 514978
The parameter
Packit 514978
.I name
Packit 514978
gives the query name as a NUL-terminated C string of period-separated
Packit 514978
labels optionally ending with a period; periods and backslashes within
Packit 514978
a label must be escaped with a backslash.  The parameters
Packit 514978
.I dnsclass
Packit 514978
and
Packit 514978
.I type
Packit 514978
give the class and type of the query using the values defined in
Packit 514978
.BR <arpa/nameser.h> .
Packit 514978
When the query is complete or has failed, the ares library will invoke
Packit 514978
.IR callback .
Packit 514978
Completion or failure of the query may happen immediately, or may
Packit 514978
happen during a later call to
Packit 514978
.BR ares_process (3)
Packit 514978
or
Packit 514978
.BR ares_destroy (3).
Packit 514978
.PP
Packit 514978
The callback argument
Packit 514978
.I arg
Packit 514978
is copied from the
Packit 514978
.B ares_query
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 query completed successfully.
Packit 514978
.TP 19
Packit 514978
.B ARES_ENODATA
Packit 514978
The query completed but contains no answers.
Packit 514978
.TP 19
Packit 514978
.B ARES_EFORMERR
Packit 514978
The query completed but the server claims that the query was
Packit 514978
malformatted.
Packit 514978
.TP 19
Packit 514978
.B ARES_ESERVFAIL
Packit 514978
The query completed but the server claims to have experienced a
Packit 514978
failure.  (This code can only occur if the
Packit 514978
.B ARES_FLAG_NOCHECKRESP
Packit 514978
flag was specified at channel initialization time; otherwise, such
Packit 514978
responses are ignored at the
Packit 514978
.BR ares_send (3)
Packit 514978
level.)
Packit 514978
.TP 19
Packit 514978
.B ARES_ENOTFOUND
Packit 514978
The query completed but the queried-for domain name was not found.
Packit 514978
.TP 19
Packit 514978
.B ARES_ENOTIMP
Packit 514978
The query completed but the server does not implement the operation
Packit 514978
requested by the query.  (This code can only occur if the
Packit 514978
.B ARES_FLAG_NOCHECKRESP
Packit 514978
flag was specified at channel initialization time; otherwise, such
Packit 514978
responses are ignored at the
Packit 514978
.BR ares_send (3)
Packit 514978
level.)
Packit 514978
.TP 19
Packit 514978
.B ARES_EREFUSED
Packit 514978
The query completed but the server refused the query.  (This code can
Packit 514978
only occur if the
Packit 514978
.B ARES_FLAG_NOCHECKRESP
Packit 514978
flag was specified at channel initialization time; otherwise, such
Packit 514978
responses are ignored at the
Packit 514978
.BR ares_send (3)
Packit 514978
level.)
Packit 514978
.TP 19
Packit 514978
.B ARES_EBADNAME
Packit 514978
The query name
Packit 514978
.I name
Packit 514978
could not be encoded as a domain name, either because it contained a
Packit 514978
zero-length label or because it contained a label of more than 63
Packit 514978
characters.
Packit 514978
.TP 19
Packit 514978
.B ARES_ETIMEOUT
Packit 514978
No name servers responded within the timeout period.
Packit 514978
.TP 19
Packit 514978
.B ARES_ECONNREFUSED
Packit 514978
No name servers could be contacted.
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
.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
If the query completed (even if there was something wrong with it, as
Packit 514978
indicated by some of the above error codes), the callback argument
Packit 514978
.I abuf
Packit 514978
points to a result buffer of length
Packit 514978
.IR alen .
Packit 514978
If the query did not complete,
Packit 514978
.I abuf
Packit 514978
will be NULL and
Packit 514978
.I alen
Packit 514978
will be 0.
Packit 514978
.SH SEE ALSO
Packit 514978
.BR ares_process (3)
Packit 514978
.SH AUTHOR
Packit 514978
Greg Hudson, MIT Information Systems
Packit 514978
.br
Packit 514978
Copyright 1998 by the Massachusetts Institute of Technology.