Commit | Line | Data |
---|---|---|
dc0d77d7 CE |
1 | #include "byte.h" |
2 | #include "dns.h" | |
3 | #include "dd.h" | |
4 | #include "response.h" | |
5 | ||
6 | const char *fatal = "walldns: fatal: "; | |
7 | const char *starting = "starting walldns\n"; | |
8 | ||
9 | void initialize(void) | |
10 | { | |
11 | ; | |
12 | } | |
13 | ||
14 | int respond(char *q,char qtype[2]) | |
15 | { | |
16 | int flaga; | |
17 | int flagptr; | |
18 | char ip[4]; | |
19 | int j; | |
20 | ||
21 | flaga = byte_equal(qtype,2,DNS_T_A); | |
22 | flagptr = byte_equal(qtype,2,DNS_T_PTR); | |
23 | if (byte_equal(qtype,2,DNS_T_ANY)) flaga = flagptr = 1; | |
24 | ||
25 | if (flaga || flagptr) { | |
26 | if (dd(q,"",ip) == 4) { | |
27 | if (flaga) { | |
28 | if (!response_rstart(q,DNS_T_A,655360)) return 0; | |
29 | if (!response_addbytes(ip,4)) return 0; | |
30 | response_rfinish(RESPONSE_ANSWER); | |
31 | } | |
32 | return 1; | |
33 | } | |
34 | j = dd(q,"\7in-addr\4arpa",ip); | |
35 | if (j >= 0) { | |
36 | if (flaga && (j == 4)) { | |
37 | if (!response_rstart(q,DNS_T_A,655360)) return 0; | |
38 | if (!response_addbytes(ip + 3,1)) return 0; | |
39 | if (!response_addbytes(ip + 2,1)) return 0; | |
40 | if (!response_addbytes(ip + 1,1)) return 0; | |
41 | if (!response_addbytes(ip + 0,1)) return 0; | |
42 | response_rfinish(RESPONSE_ANSWER); | |
43 | } | |
44 | if (flagptr) { | |
45 | if (!response_rstart(q,DNS_T_PTR,655360)) return 0; | |
46 | if (!response_addname(q)) return 0; | |
47 | response_rfinish(RESPONSE_ANSWER); | |
48 | } | |
49 | return 1; | |
50 | } | |
51 | } | |
52 | ||
53 | response[2] &= ~4; | |
54 | response[3] &= ~15; | |
55 | response[3] |= 5; | |
56 | return 1; | |
57 | } |