quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

ares_query.3 (5013B)


      1 .\"
      2 .\" Copyright 1998 by the Massachusetts Institute of Technology.
      3 .\" SPDX-License-Identifier: MIT
      4 .\"
      5 .TH ARES_QUERY 3 "24 July 1998"
      6 .SH NAME
      7 ares_query \- Initiate a single-question DNS query
      8 .SH SYNOPSIS
      9 .nf
     10 #include <ares.h>
     11 
     12 typedef void (*ares_callback_dnsrec)(void *arg, ares_status_t status,
     13                                      size_t timeouts,
     14                                      const ares_dns_record_t *dnsrec);
     15 
     16 ares_status_t ares_query_dnsrec(ares_channel_t      *channel,
     17                                 const char          *name,
     18                                 ares_dns_class_t     dnsclass,
     19                                 ares_dns_rec_type_t  type,
     20                                 ares_callback_dnsrec callback,
     21                                 void                *arg,
     22                                 unsigned short      *qid);
     23 
     24 typedef void (*ares_callback)(void *arg, int status,
     25                               int timeouts, unsigned char *abuf,
     26                               int alen);
     27 
     28 void ares_query(ares_channel_t *channel, const char *name,
     29                 int dnsclass, int type,
     30                 ares_callback callback, void *arg);
     31 
     32 .fi
     33 
     34 .SH DESCRIPTION
     35 
     36 The \fBares_query_dnsrec(3)\fP and \fBares_query(3)\fP functions initiate a
     37 single-question DNS query on the name service channel identified by
     38 .IR channel .
     39 The parameter
     40 .I name
     41 gives the query name as a NUL-terminated C string of period-separated
     42 labels optionally ending with a period; periods and backslashes within
     43 a label must be escaped with a backslash.  The parameters
     44 .I dnsclass
     45 and
     46 .I type
     47 give the class and type of the query.
     48 
     49 \fBares_query_dnsrec(3)\fP uses the ares \fBares_dns_class_t\fP and
     50 \fBares_dns_rec_type_t\fP defined types.  However, \fBares_query(3)\fP uses
     51 the values defined in \fB<arpa/nameser.h>\fP.
     52 
     53 When the query is complete or has failed, the ares library will invoke
     54 .IR callback .
     55 Completion or failure of the query may happen immediately (even before the
     56 return of the function call), or may happen during a later call to
     57 \fBares_process(3)\fP or \fBares_destroy(3)\fP.
     58 
     59 If this is called from a thread other than which the main program event loop is
     60 running, care needs to be taken to ensure any file descriptor lists are updated
     61 immediately within the eventloop.  When the associated callback is called,
     62 it is called with a channel lock so care must be taken to ensure any processing
     63 is minimal to prevent DNS channel stalls.
     64 
     65 The callback argument
     66 .I arg
     67 is copied from the \fBares_query_dnsrec(3)\fP or \fBares_query(3)\fP argument
     68 .IR arg .
     69 The callback argument
     70 .I status
     71 indicates whether the query succeeded and, if not, how it failed.  It
     72 may have any of the following values:
     73 .TP 19
     74 .B ARES_SUCCESS
     75 The query completed successfully.
     76 .TP 19
     77 .B ARES_ENODATA
     78 The query completed but contains no answers.
     79 .TP 19
     80 .B ARES_EFORMERR
     81 The query completed but the server claims that the query was
     82 malformatted.
     83 .TP 19
     84 .B ARES_ESERVFAIL
     85 The query completed but the server claims to have experienced a
     86 failure.  (This code can only occur if the
     87 .B ARES_FLAG_NOCHECKRESP
     88 flag was specified at channel initialization time; otherwise, such
     89 responses are ignored at the \fBares_send_dnsrec(3)\fP level.)
     90 .TP 19
     91 .B ARES_ENOTFOUND
     92 The query completed but the queried-for domain name was not found.
     93 .TP 19
     94 .B ARES_ENOTIMP
     95 The query completed but the server does not implement the operation
     96 requested by the query.  (This code can only occur if the
     97 .B ARES_FLAG_NOCHECKRESP
     98 flag was specified at channel initialization time; otherwise, such
     99 responses are ignored at the \fBares_send_dnsrec(3)\fP level.)
    100 .TP 19
    101 .B ARES_EREFUSED
    102 The query completed but the server refused the query.  (This code can
    103 only occur if the
    104 .B ARES_FLAG_NOCHECKRESP
    105 flag was specified at channel initialization time; otherwise, such
    106 responses are ignored at the \fBares_send_dnsrec(3)\fP level.)
    107 .TP 19
    108 .B ARES_EBADNAME
    109 The query name
    110 .I name
    111 could not be encoded as a domain name, either because it contained a
    112 zero-length label or because it contained a label of more than 63
    113 characters.
    114 .TP 19
    115 .B ARES_ETIMEOUT
    116 No name servers responded within the timeout period.
    117 .TP 19
    118 .B ARES_ECONNREFUSED
    119 No name servers could be contacted.
    120 .TP 19
    121 .B ARES_ENOMEM
    122 Memory was exhausted.
    123 .TP 19
    124 .B ARES_ECANCELLED
    125 The query was cancelled.
    126 .TP 19
    127 .B ARES_EDESTRUCTION
    128 The name service channel
    129 .I channel
    130 is being destroyed; the query will not be completed.
    131 .TP 19
    132 .B ARES_ENOSERVER
    133 The query will not be completed because no DNS servers were configured on the
    134 channel.
    135 .PP
    136 
    137 The callback argument
    138 .I timeouts
    139 reports how many times a query timed out during the execution of the
    140 given request.
    141 
    142 If the query completed (even if there was something wrong with it, as
    143 indicated by some of the above error codes), the callback argument
    144 .I dnsrec
    145 or
    146 .I abuf
    147 will be non-NULL, otherwise they will be NULL.
    148 
    149 .SH AVAILABILITY
    150 \fBares_query_dnsrec(3)\fP was introduced in c-ares 1.28.0.
    151 
    152 .SH SEE ALSO
    153 .BR ares_process (3),
    154 .BR ares_dns_record (3)