fehQlibs 26
Qlibs
Loading...
Searching...
No Matches
dns_resolve.c
Go to the documentation of this file.
1#include "iopause.h"
2#include "taia.h"
3#include "byte.h"
4#include "ip.h"
5#include "dnsresolv.h"
6
15
16int dns_resolve(const char *q,const char qtype[2])
17{
18 struct taia stamp;
19 struct taia deadline;
20 char servers[QUERY_MAXIPLEN];
21 uint32 scopes[QUERY_MAXNS];
22 iopause_fd x[1];
23 int r;
24
25 if (dns_resolvconfip(servers,scopes) < 0) return DNS_INT;
26
27 if (dns_transmit_start6(&dns_resolve_tx,servers,1,q,qtype,(const char *)V6localnet,scopes) < 0) return DNS_COM;
28
29 for (;;) {
30 taia_now(&stamp);
31 taia_uint(&deadline,120);
32 taia_add(&deadline,&deadline,&stamp);
33 dns_transmit_io(&dns_resolve_tx,x,&deadline);
34 iopause(x,1,&deadline,&stamp);
35 r = dns_transmit_get(&dns_resolve_tx,x,&stamp);
36 if (r < 0) return DNS_COM;
37 if (r == 1) return 0;
38 }
39}
const unsigned char V6localnet[16]
Definition: socket_if.c:19
int dns_resolve(const char *q, const char qtype[2])
Definition: dns_resolve.c:16
struct dns_transmit dns_resolve_tx
Definition: dns_resolve.c:14
int iopause(iopause_fd *, unsigned int, struct taia *, struct taia *)
Definition: iopause.c:14
uint32_t uint32
Definition: uint_t.h:40
void taia_add(struct taia *, struct taia *, struct taia *)
Definition: taia.c:14
void taia_uint(struct taia *, unsigned int)
Definition: taia.c:99
int taia_now(struct taia *)
Definition: taia.c:48
void dns_transmit_io(struct dns_transmit *, iopause_fd *, struct taia *)
Definition: dns_transmit.c:294
int dns_resolvconfip(char *, uint32 *)
#define QUERY_MAXIPLEN
Definition: dnsresolv.h:56
#define DNS_INT
Definition: dnsresolv.h:46
#define QUERY_MAXNS
Definition: dnsresolv.h:55
int dns_transmit_start6(struct dns_transmit *, const char *, int, const char *, const char *, const char *, const uint32 *)
#define DNS_COM
Definition: dnsresolv.h:45
int dns_transmit_get(struct dns_transmit *, const iopause_fd *, const struct taia *)
Definition: dns_transmit.c:311
char qtype[2]
Definition: dnsresolv.h:113
Definition: taia.h:13