24static const int timeouts[5] = { 1, 2, 4, 8, 16 };
30 if (
byte_diff(ip,2,V6linklocal))
return 0;
43 if (out[2] & 2)
return 1;
56 if (rcode && (rcode != 3)) { errno = EAGAIN;
return 1; }
61static int irrelevant(
const struct dns_transmit *d,
const char *buf,
unsigned int len)
69 if (out[4] != 0)
return 1;
70 if (out[5] != 1)
return 1;
93 if (!d->
query)
return;
116 for (j = 0; j < 10; ++j) {
130 for (j = 0; j < 10; ++j) {
230 if ((errno == EINPROGRESS) || (errno == EWOULDBLOCK)) {
256 int flagrecursive,
const char *q,
const char qtype[2],
const char localip[16])
269 byte_copy(d->
query + 2,12,flagrecursive ?
"\0\0\1\0\0\1\0\0\0\0\0\0" : \
270 "\0\0\0\0\0\1\0\0\0\0\0\0gcc-bug-workaround");
279 d->
udploop = flagrecursive ? 1 : 0;
286 int flagrecursive,
const char *q,
const char qtype[2], \
299 case 0:
case 3:
case 4:
case 5:
333 r = recv(fd,udpbuf,
sizeof(udpbuf),0);
335 if (errno == ECONNREFUSED)
if (d->
udploop == 2)
return 0;
338 if (r + 1 >
sizeof(udpbuf))
return 0;
340 if (irrelevant(d,udpbuf,r))
return 0;
int read(int _str, void *_buf, int _b)
void dns_transmit_io(struct dns_transmit *d, iopause_fd *x, struct taia *deadline)
void socketfree(struct dns_transmit *d)
void packetfree(struct dns_transmit *d)
void dns_transmit_free(struct dns_transmit *d)
int randombind6(struct dns_transmit *d)
int getscopeid(const struct dns_transmit *d, const char *ip)
int randombind4(struct dns_transmit *d)
int firstudp(struct dns_transmit *d)
int dns_transmit_start6(struct dns_transmit *d, const char servers[QUERY_MAXIPLEN], int flagrecursive, const char *q, const char qtype[2], const char localip[16], const uint32 scopes[QUERY_MAXNS])
int nexttcp(struct dns_transmit *d)
int serverfailed(const char *buf, unsigned int len)
int serverwantstcp(const char *buf, unsigned int len)
uint32 scope_ids[QUERY_MAXNS]
void queryfree(struct dns_transmit *d)
int dns_transmit_start(struct dns_transmit *d, const char servers[QUERY_MAXIPLEN], int flagrecursive, const char *q, const char qtype[2], const char localip[16])
int dns_transmit_get(struct dns_transmit *d, const iopause_fd *x, const struct taia *when)
int nextudp(struct dns_transmit *d)
int firsttcp(struct dns_transmit *d)
void * alloc(unsigned int)
additional types and pack routines
void uint16_pack_big(char[16], uint16)
#define ip6_isv4mapped(ip)
int socket_bind4(int, const char[4], uint16)
int socket_connected(int)
int socket_bind6(int, const char[16], uint16, uint32)
int socket_connect(int, const char[16], uint16, uint32)
int taia_less(struct taia *, struct taia *)
void taia_add(struct taia *, struct taia *, struct taia *)
void taia_uint(struct taia *, unsigned int)
int taia_now(struct taia *)
int byte_diff(const void *, unsigned int, const void *)
void byte_copy(void *, unsigned int, const void *)
#define byte_equal(s, n, t)
unsigned int dns_packet_copy(const char *, unsigned int, unsigned int, char *, unsigned int)
int dns_domain_equal(const char *, const char *)
unsigned int dns_random(unsigned int)
unsigned int dns_domain_length(const char *)
unsigned int dns_packet_getname(const char *, unsigned int, unsigned int, char **)