-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrecurtest.c
More file actions
45 lines (33 loc) · 807 Bytes
/
recurtest.c
File metadata and controls
45 lines (33 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* Test a nameserver to see if it might allow recursive queries. */
#include<string.h>
#include<netinet/in.h>
#include<arpa/nameser.h>
#include<resolv.h>
#include<errno.h>
#include<netdb.h>
#include<unistd.h>
#include<pthread.h>
#include"dnsqry.h"
extern pthread_mutex_t mutex;
int
recurtest(struct hostent *host, char *domain)
{
u_char fixedans[PACKETSZ], *answer;
int len;
answer = fixedans;
#ifdef DEBUG
tdpf("pthread_mutex_lock(&mutex)");
#endif
pthread_mutex_lock(&mutex);
res_init();
memcpy((void *)&_res.nsaddr_list[0].sin_addr,
(void *)host->h_addr_list[0], (size_t) host->h_length);
len = res_query(domain, C_IN, T_A, answer, PACKETSZ);
#ifdef DEBUG
tdpf("pthread_mutex_unlock(&mutex)");
#endif
pthread_mutex_unlock(&mutex);
if (len == -1)
return 1;
return 0;
}