#include "ares_private.h"#include "ares_dns.h"Include dependency graph for ares_query.c:
Go to the source code of this file.
Data Structures | |
| struct | qquery |
Functions | |
| void | qcallback (void *arg, int status, unsigned char *abuf, int alen) |
| void | ares_query (ares_channel channel, const char *name, int dnsclass, int type, ares_callback callback, void *arg) |
|
||||||||||||||||||||||||||||
|
Definition at line 33 of file ares_query.c. References ares_callback, ares_channel, ARES_ENOMEM, ARES_FLAG_NORECURSE, ares_free_string(), ares_mkquery(), ares_send(), ARES_SUCCESS, callback(), ares_channeldata::flags, malloc, name, ares_channeldata::next_id, NULL, qcallback(), and status. Referenced by ares_search(), next_lookup(), and search_callback().
00035 {
00036 struct qquery *qquery;
00037 unsigned char *qbuf;
00038 int qlen, rd, status;
00039
00040 /* Compose the query. */
00041 rd = !(channel->flags & ARES_FLAG_NORECURSE);
00042 status = ares_mkquery(name, dnsclass, type, channel->next_id, rd, &qbuf,
00043 &qlen);
00044 channel->next_id++;
00045 if (status != ARES_SUCCESS)
00046 {
00047 callback(arg, status, NULL, 0);
00048 return;
00049 }
00050
00051 /* Allocate and fill in the query structure. */
00052 qquery = malloc(sizeof(struct qquery));
00053 if (!qquery)
00054 {
00055 ares_free_string(qbuf);
00056 callback(arg, ARES_ENOMEM, NULL, 0);
00057 return;
00058 }
00059 qquery->callback = callback;
00060 qquery->arg = arg;
00061
00062 /* Send it off. qcallback will be called when we get an answer. */
00063 ares_send(channel, qbuf, qlen, qcallback, qquery);
00064 ares_free_string(qbuf);
00065 }
|
Here is the call graph for this function:
|
||||||||||||||||||||
|
Definition at line 67 of file ares_query.c. References ARES_EFORMERR, ARES_ENODATA, ARES_ENOTFOUND, ARES_ENOTIMP, ARES_EREFUSED, ARES_ESERVFAIL, ARES_SUCCESS, DNS_HEADER_ANCOUNT, DNS_HEADER_RCODE, FORMERR, free, NOERROR, NOTIMP, NXDOMAIN, REFUSED, SERVFAIL, and status. Referenced by ares_query().
00068 {
00069 struct qquery *qquery = (struct qquery *) arg;
00070 unsigned int ancount;
00071 int rcode;
00072
00073 if (status != ARES_SUCCESS)
00074 qquery->callback(qquery->arg, status, abuf, alen);
00075 else
00076 {
00077 /* Pull the response code and answer count from the packet. */
00078 rcode = DNS_HEADER_RCODE(abuf);
00079 ancount = DNS_HEADER_ANCOUNT(abuf);
00080
00081 /* Convert errors. */
00082 switch (rcode)
00083 {
00084 case NOERROR:
00085 status = (ancount > 0) ? ARES_SUCCESS : ARES_ENODATA;
00086 break;
00087 case FORMERR:
00088 status = ARES_EFORMERR;
00089 break;
00090 case SERVFAIL:
00091 status = ARES_ESERVFAIL;
00092 break;
00093 case NXDOMAIN:
00094 status = ARES_ENOTFOUND;
00095 break;
00096 case NOTIMP:
00097 status = ARES_ENOTIMP;
00098 break;
00099 case REFUSED:
00100 status = ARES_EREFUSED;
00101 break;
00102 }
00103 qquery->callback(qquery->arg, status, abuf, alen);
00104 }
00105 free(qquery);
00106 }
|
1.3.4