1 | // dns_resolver.h - #define statements for the DNS resolver
|
---|
2 |
|
---|
3 | // We only need A and CNAME queries (later possibly AAAA/A6?)
|
---|
4 | #define QUERYTYPE_A 1
|
---|
5 | #define QUERYTYPE_CNAME 5
|
---|
6 |
|
---|
7 | // We only query with INTERNET class (not CHAOS or whatever)
|
---|
8 | #define QUERYCLASS_INET 1
|
---|
9 |
|
---|
10 | // Our first query will have the identifier <1> (arbitrary -
|
---|
11 | // remember however that (256 - QUERYIDENTIFIER)/2 > MAX_CNAME_RECURSION !!!
|
---|
12 | #define QUERYIDENTIFIER 1
|
---|
13 |
|
---|
14 | // Query flags are standard values here
|
---|
15 | #define QUERYFLAGS 0x0100
|
---|
16 | #define QUERYFLAGS_MASK 0xf8
|
---|
17 | #define QUERYFLAGS_WANT 0x80
|
---|
18 |
|
---|
19 | // Indices inside the byte array that holds DNS queries/answers
|
---|
20 | #define QINDEX_ID 0
|
---|
21 | #define QINDEX_FLAGS 2
|
---|
22 | #define QINDEX_NUMQUEST 4
|
---|
23 | #define QINDEX_NUMANSW 6
|
---|
24 | #define QINDEX_NUMAUTH 8
|
---|
25 | #define QINDEX_NUMADDIT 10
|
---|
26 | #define QINDEX_QUESTION 12
|
---|
27 | #define QINDEX_QTYPE 14
|
---|
28 | #define QINDEX_QCLASS 16
|
---|
29 | #define QINDEX_STORE_A 256
|
---|
30 |
|
---|
31 | // Constant UDP port number for DNS traffic
|
---|
32 | #define UDP_PORT_DNS 53
|
---|
33 |
|
---|
34 | // Return values that the package parser may give
|
---|
35 | // This packet was not for us (broadcast or whatever)
|
---|
36 | #define RET_PACK_GARBAG 0
|
---|
37 | // Retrieved an address - query finishes
|
---|
38 | #define RET_GOT_ADDR 1
|
---|
39 | // No A record for that hostname - try running a CNAME query
|
---|
40 | #define RET_RUN_CNAME_Q 2
|
---|
41 | // The CNAME query returned a valid hostname - run A query on that
|
---|
42 | #define RET_RUN_NEXT_A 3
|
---|
43 | // The CNAME query failed - stop resolving
|
---|
44 | #define RET_CNAME_FAIL 4
|
---|
45 | // We have a reliable input that claims that the hostname does not exist
|
---|
46 | #define RET_NOSUCHNAME 5
|
---|
47 | // The name server response is somehow bogus/can not be parsed -> Abort
|
---|
48 | #define RET_DNSERROR 6
|
---|
49 |
|
---|
50 | // Return values that the query engine may give
|
---|
51 | // DNS query succeeded, IP address delivered
|
---|
52 | #define RET_DNS_OK 0
|
---|
53 | // DNS query failed
|
---|
54 | #define RET_DNS_FAIL 1
|
---|
55 |
|
---|
56 | // Error codes the DNS server can send to us
|
---|
57 | #define ERR_NOSUCHNAME 3
|
---|
58 |
|
---|