diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-01 23:00:59 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-01 23:00:59 +0000 |
commit | 66ffc809472f27d69b9ad7361f8ba29c2674f716 (patch) | |
tree | 609623cb79291939f9cb81a8858853a202dae2ca /src/include/gnunet_dnsparser_lib.h | |
parent | 131c43b2b18b12e52ff045e51025706802cbd2e2 (diff) | |
download | gnunet-66ffc809472f27d69b9ad7361f8ba29c2674f716.tar.gz gnunet-66ffc809472f27d69b9ad7361f8ba29c2674f716.zip |
-moving DNS code into its own directory
Diffstat (limited to 'src/include/gnunet_dnsparser_lib.h')
-rw-r--r-- | src/include/gnunet_dnsparser_lib.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/include/gnunet_dnsparser_lib.h b/src/include/gnunet_dnsparser_lib.h new file mode 100644 index 000000000..a9ed5b3b2 --- /dev/null +++ b/src/include/gnunet_dnsparser_lib.h | |||
@@ -0,0 +1,95 @@ | |||
1 | #ifndef _GNVPN_DNSP_H_ | ||
2 | #define _GNVPN_DNSP_H_ | ||
3 | |||
4 | #include "platform.h" | ||
5 | #include "gnunet_common.h" | ||
6 | |||
7 | // DNS-Stuff | ||
8 | GNUNET_NETWORK_STRUCT_BEGIN | ||
9 | |||
10 | struct dns_static | ||
11 | { | ||
12 | uint16_t id GNUNET_PACKED; | ||
13 | |||
14 | unsigned rd:1 GNUNET_PACKED; // recursion desired (client -> server) | ||
15 | unsigned tc:1 GNUNET_PACKED; // message is truncated | ||
16 | unsigned aa:1 GNUNET_PACKED; // authoritative answer | ||
17 | unsigned op:4 GNUNET_PACKED; // query:0, inverse q.:1, status: 2 | ||
18 | unsigned qr:1 GNUNET_PACKED; // query:0, response:1 | ||
19 | |||
20 | unsigned rcode:4 GNUNET_PACKED; // 0 No error | ||
21 | // 1 Format error | ||
22 | // 2 Server failure | ||
23 | // 3 Name Error | ||
24 | // 4 Not Implemented | ||
25 | // 5 Refused | ||
26 | unsigned z:3 GNUNET_PACKED; // reserved | ||
27 | unsigned ra:1 GNUNET_PACKED; // recursion available (server -> client) | ||
28 | |||
29 | uint16_t qdcount GNUNET_PACKED; // number of questions | ||
30 | uint16_t ancount GNUNET_PACKED; // number of answers | ||
31 | uint16_t nscount GNUNET_PACKED; // number of authority-records | ||
32 | uint16_t arcount GNUNET_PACKED; // number of additional records | ||
33 | }; | ||
34 | GNUNET_NETWORK_STRUCT_END | ||
35 | |||
36 | struct dns_pkt | ||
37 | { | ||
38 | struct dns_static s; | ||
39 | unsigned char data[1]; | ||
40 | }; | ||
41 | |||
42 | struct dns_pkt_parsed | ||
43 | { | ||
44 | struct dns_static s; | ||
45 | struct dns_query **queries; | ||
46 | struct dns_record **answers; | ||
47 | struct dns_record **nameservers; | ||
48 | struct dns_record **additional; | ||
49 | }; | ||
50 | |||
51 | struct dns_query_line | ||
52 | { | ||
53 | unsigned short type; | ||
54 | unsigned short class; | ||
55 | }; | ||
56 | |||
57 | struct dns_query | ||
58 | { | ||
59 | char *name; | ||
60 | unsigned char namelen; | ||
61 | unsigned short qtype; | ||
62 | unsigned short qclass; | ||
63 | }; | ||
64 | |||
65 | struct dns_record_line | ||
66 | { | ||
67 | unsigned short type; | ||
68 | unsigned short class; | ||
69 | unsigned int ttl; | ||
70 | unsigned short data_len; | ||
71 | unsigned char data; | ||
72 | }; | ||
73 | |||
74 | struct dns_record | ||
75 | { | ||
76 | char *name; | ||
77 | unsigned char namelen; | ||
78 | unsigned short type; | ||
79 | unsigned short class; | ||
80 | unsigned int ttl; | ||
81 | unsigned short data_len; | ||
82 | unsigned char *data; | ||
83 | }; | ||
84 | |||
85 | |||
86 | struct dns_pkt_parsed * | ||
87 | parse_dns_packet (struct dns_pkt *pkt); | ||
88 | |||
89 | struct dns_pkt * | ||
90 | unparse_dns_packet (struct dns_pkt_parsed *pkt); | ||
91 | |||
92 | void | ||
93 | free_parsed_dns_packet (struct dns_pkt_parsed *ppkt); | ||
94 | |||
95 | #endif | ||