Commit | Line | Data |
---|---|---|
dc0d77d7 CE |
1 | #include "iopause.h" |
2 | #include "taia.h" | |
3 | #include "byte.h" | |
4 | #include "dns.h" | |
5 | ||
6 | struct dns_transmit dns_resolve_tx = {0}; | |
7 | ||
8 | int dns_resolve(const char *q,const char qtype[2]) | |
9 | { | |
10 | struct taia stamp; | |
11 | struct taia deadline; | |
12 | char servers[64]; | |
13 | iopause_fd x[1]; | |
14 | int r; | |
15 | ||
16 | if (dns_resolvconfip(servers) == -1) return -1; | |
17 | if (dns_transmit_start(&dns_resolve_tx,servers,1,q,qtype,"\0\0\0\0") == -1) return -1; | |
18 | ||
19 | for (;;) { | |
20 | taia_now(&stamp); | |
21 | taia_uint(&deadline,120); | |
22 | taia_add(&deadline,&deadline,&stamp); | |
23 | dns_transmit_io(&dns_resolve_tx,x,&deadline); | |
24 | iopause(x,1,&deadline,&stamp); | |
25 | r = dns_transmit_get(&dns_resolve_tx,x,&stamp); | |
26 | if (r == -1) return -1; | |
27 | if (r == 1) return 0; | |
28 | } | |
29 | } |