dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina Async resolver
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina Martin Nagy <mnagy@redhat.com>
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina Jakub Hrozek <jhrozek@redhat.com>
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina Copyright (C) Red Hat, Inc 2009
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina This program is free software; you can redistribute it and/or modify
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina it under the terms of the GNU General Public License as published by
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina the Free Software Foundation; either version 3 of the License, or
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina (at your option) any later version.
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina This program is distributed in the hope that it will be useful,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina GNU General Public License for more details.
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina You should have received a copy of the GNU General Public License
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * Macro DNS__32BIT reads a network long (32 bit) given in network
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * byte order, and returns its value as an unsigned int. Copied
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * from c-ares source code.
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina (((unsigned int)((unsigned char)(p)[0]) << 24U) | \
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ((unsigned int)((unsigned char)(p)[1]) << 16U) | \
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ((unsigned int)((unsigned char)(p)[2]) << 8U) | \
switch (ares_code) {
case ARES_SUCCESS:
return EOK;
case ARES_ENOMEM:
return ENOMEM;
case ARES_EFILE:
return EIO;
ctx);
static struct resolv_request *
if (!rreq) {
return NULL;
rreq);
return NULL;
return NULL;
return rreq;
static struct resolv_request *
return rreq;
while (watch) {
while (watch) {
return EOK;
return ENOMEM;
goto done;
return EOK;
done:
return ret;
static errno_t
return EOK;
static errno_t
return EOK;
static struct resolv_hostent *
return NULL;
goto fail;
goto fail;
for (i = 0; i < len; i++) {
goto fail;
return ret;
fail:
return NULL;
struct resolv_hostent *
return NULL;
goto fail;
for (i = 0; i < len; i++) {
struct resolv_addr);
goto fail;
goto fail;
return ret;
fail:
return NULL;
struct resolv_hostent *
int num_ares_ttl_data)
return NULL;
if (num_ares_ttl_data > 0) {
goto fail;
for (i = 0; i < num_ares_ttl_data; i++) {
struct resolv_addr);
goto fail;
switch (family) {
case AF_INET:
case AF_INET6:
goto fail;
goto fail;
return ret;
fail:
return NULL;
static struct tevent_req *
const char *name,
int family)
struct gethostbyname_files_state);
return NULL;
&hostent);
goto done;
goto done;
goto done;
done:
return req;
static errno_t
struct gethostbyname_files_state);
if (status) {
if (rhostent) {
return EOK;
static struct tevent_req *
int family)
return NULL;
return NULL;
return NULL;
return req;
struct tevent_req);
struct gethostbyname_dns_state);
if (!rreq) {
/* If resolv.conf changed during processing of a request we might
case AF_INET:
if (!addr) {
goto fail;
&naddrttls);
case AF_INET6:
if (!addr) {
goto fail;
&naddrttls);
goto fail;
goto fail;
return ENOENT;
fail:
return ret;
struct gethostbyname_dns_state);
if (status) {
if (timeouts) {
if (rhostent) {
return EOK;
static errno_t
static errno_t
struct tevent_req *
return NULL;
return NULL;
goto fail;
goto fail;
return req;
goto fail;
return req;
fail:
return NULL;
if (ret != 0) {
return ret == 0;
static errno_t
if (!rhostent) {
goto done;
goto done;
struct resolv_addr);
goto done;
sizeof(struct in6_addr));
goto done;
goto done;
done:
return ret;
switch(family_order) {
case IPV4_ONLY:
case IPV4_FIRST:
return AF_INET;
case IPV6_ONLY:
case IPV6_FIRST:
return AF_INET6;
return EOK;
return EOK;
return EOK;
return ENOENT;
static errno_t
struct gethostbyname_state);
case DB_FILES:
case DB_DNS:
return EINVAL;
return ENOMEM;
return EOK;
struct tevent_req);
struct gethostbyname_state);
case DB_FILES:
case DB_DNS:
if (status) {
if (timeouts) {
if (rhostent) {
return EOK;
unsigned int addrindex)
return NULL;
errno = 0;
return NULL;
return address;
if (!straddr) {
return NULL;
(address[0]));
return NULL;
return straddr;
struct sockaddr_storage *
return NULL;
case AF_INET:
sizeof(struct in_addr));
case AF_INET6:
sizeof(struct in6_addr));
return NULL;
return sockaddr;
if (!old_list) {
return EOK;
while (old_list) {
if (!new_list) {
return ENOMEM;
return ENOMEM;
return ENOMEM;
return EOK;
/* the SRV query - for example _ldap._tcp.example.com */
struct tevent_req *
return NULL;
return NULL;
return NULL;
return req;
* Implemented based on http://tools.ietf.org/html/rfc2181#section-5
if (ancount == 0) {
for (i = 0; i < ancount; i++) {
if (ttl > 0) {
goto fail;
goto fail;
goto fail;
if (ok == false) {
fail:
if (status)
if (timeouts)
if (reply_list)
if (ttl) {
return EOK;
struct tevent_req);
struct getsrv_state);
if (!rreq) {
#ifdef BUILD_TXT
if (!old_list) {
return EOK;
while (old_list) {
if (!new_list) {
return ENOMEM;
return ENOMEM;
return ENOMEM;
return EOK;
struct tevent_req *
return NULL;
return NULL;
return NULL;
return req;
goto fail;
goto fail;
goto fail;
fail:
if (status)
if (timeouts)
if (reply_list)
return EOK;
struct tevent_req);
struct gettxt_state);
if (!rreq) {
if (!list) {
return NULL;
return single_step;
struct ares_srv_reply *l, *r;
if (!left)
return right;
if (!right)
return left;
r = right;
l = left;
res = l;
l = l->next;
res = r;
r = r->next;
return res_start;
return list;
return list;
return EOK;
if (!totals) {
return ENOMEM;
r = *(start);
while (r != NULL) {
tmp = r;
r = r->next;
prev = r;
r = r->next;
total = 0;
prev = r;
goto done;
if (prev) {
if (!new_start) {
new_start = r;
new_end = r;
new_end = r;
done:
return ret;
return EIO;
while (pri_start) {
len++;
if (ret) {
return ret;
if (prev_end) {
return EOK;