int __dns_parse(const unsigned char *, int, int (*)(void *, int, const void *, int, const void *), void *);
int __dn_expand(const unsigned char *, const unsigned char *, const unsigned char *, char *, int);
int __res_mkquery(int, const char *, int, int, const unsigned char *, int, const unsigned char*, unsigned char *, int);
-int __res_msend(int, const unsigned char *const *, const int *, unsigned char *const *, int *, int);
+int __res_msend_rc(int, const unsigned char *const *, const int *, unsigned char *const *, int *, int, const struct resolvconf *);
#define RR_A 1
#define RR_CNAME 5
return 0;
}
-static int name_from_dns(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family)
+static int name_from_dns(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, const struct resolvconf *conf)
{
unsigned char qbuf[2][280], abuf[2][512];
const unsigned char *qp[2] = { qbuf[0], qbuf[1] };
nq++;
}
- if (__res_msend(nq, qp, qlens, ap, alens, sizeof *abuf) < 0) return EAI_SYSTEM;
+ if (__res_msend_rc(nq, qp, qlens, ap, alens, sizeof *abuf, conf) < 0)
+ return EAI_SYSTEM;
for (i=0; i<nq; i++)
__dns_parse(abuf[i], alens[i], dns_parse_callback, &ctx);
if (z-p < 256 - l - 1) {
memcpy(canon+l+1, p, z-p);
canon[z-p+1+l] = 0;
- int cnt = name_from_dns(buf, canon, canon, family);
+ int cnt = name_from_dns(buf, canon, canon, family, &conf);
if (cnt) return cnt;
}
}
canon[l] = 0;
- return name_from_dns(buf, canon, name, family);
+ return name_from_dns(buf, canon, name, family, &conf);
}
static const struct policy {
+ ts.tv_nsec / 1000000;
}
-int __res_msend(int nqueries, const unsigned char *const *queries,
- const int *qlens, unsigned char *const *answers, int *alens, int asize)
+int __res_msend_rc(int nqueries, const unsigned char *const *queries,
+ const int *qlens, unsigned char *const *answers, int *alens, int asize,
+ const struct resolvconf *conf)
{
int fd;
int timeout, attempts, retry_interval, servfail_retry;
int cs;
struct pollfd pfd;
unsigned long t0, t1, t2;
- struct resolvconf conf;
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- /* Get nameservers & timeout/retry settings from resolv.conf */
- if (__get_resolv_conf(&conf, 0, 0) < 0) return -1;
-
- timeout = 1000*conf.timeout;
- attempts = conf.attempts;
+ timeout = 1000*conf->timeout;
+ attempts = conf->attempts;
- nns = conf.nns;
- for (nns=0; nns<conf.nns; nns++) {
- struct address *iplit = &conf.ns[nns];
+ nns = conf->nns;
+ for (nns=0; nns<conf->nns; nns++) {
+ const struct address *iplit = &conf->ns[nns];
if (iplit->family == AF_INET) {
memcpy(&ns[nns].sin.sin_addr, iplit->addr, 4);
ns[nns].sin.sin_port = htons(53);
return 0;
}
+
+int __res_msend(int nqueries, const unsigned char *const *queries,
+ const int *qlens, unsigned char *const *answers, int *alens, int asize)
+{
+ struct resolvconf conf;
+ if (__get_resolv_conf(&conf, 0, 0) < 0) return -1;
+ return __res_msend_rc(nqueries, queries, qlens, answers, alens, asize, &conf);
+}