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 | |
parent | 131c43b2b18b12e52ff045e51025706802cbd2e2 (diff) | |
download | gnunet-66ffc809472f27d69b9ad7361f8ba29c2674f716.tar.gz gnunet-66ffc809472f27d69b9ad7361f8ba29c2674f716.zip |
-moving DNS code into its own directory
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/Makefile.am | 1 | ||||
-rw-r--r-- | src/include/gnunet_dns_service.h | 116 | ||||
-rw-r--r-- | src/include/gnunet_dnsparser_lib.h | 95 |
3 files changed, 212 insertions, 0 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 003a90e24..417e200c2 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -40,6 +40,7 @@ gnunetinclude_HEADERS = \ | |||
40 | gnunet_datastore_plugin.h \ | 40 | gnunet_datastore_plugin.h \ |
41 | gnunet_dht_service.h \ | 41 | gnunet_dht_service.h \ |
42 | gnunet_disk_lib.h \ | 42 | gnunet_disk_lib.h \ |
43 | gnunet_dnsparser_lib.h \ | ||
43 | gnunet_dv_service.h \ | 44 | gnunet_dv_service.h \ |
44 | gnunet_fragmentation_lib.h \ | 45 | gnunet_fragmentation_lib.h \ |
45 | gnunet_fs_service.h \ | 46 | gnunet_fs_service.h \ |
diff --git a/src/include/gnunet_dns_service.h b/src/include/gnunet_dns_service.h new file mode 100644 index 000000000..632145ae2 --- /dev/null +++ b/src/include/gnunet_dns_service.h | |||
@@ -0,0 +1,116 @@ | |||
1 | #ifndef GN_DNS_SERVICE_P_H | ||
2 | #define GN_DNS_SERVICE_P_H | ||
3 | |||
4 | #include "gnunet_common.h" | ||
5 | |||
6 | GNUNET_NETWORK_STRUCT_BEGIN | ||
7 | |||
8 | struct query_packet | ||
9 | { | ||
10 | struct GNUNET_MessageHeader hdr; | ||
11 | |||
12 | /** | ||
13 | * The IP-Address this query was originally sent to | ||
14 | */ | ||
15 | char orig_to[16]; | ||
16 | /** | ||
17 | * The IP-Address this query was originally sent from | ||
18 | */ | ||
19 | char orig_from[16]; | ||
20 | /** | ||
21 | * The UDP-Portthis query was originally sent from | ||
22 | */ | ||
23 | char addrlen; | ||
24 | uint16_t src_port GNUNET_PACKED; | ||
25 | |||
26 | unsigned char data[1]; /* The DNS-Packet */ | ||
27 | }; | ||
28 | |||
29 | struct query_packet_list | ||
30 | { | ||
31 | struct query_packet_list *next GNUNET_PACKED; | ||
32 | struct query_packet_list *prev GNUNET_PACKED; | ||
33 | struct query_packet pkt; | ||
34 | }; | ||
35 | |||
36 | enum GNUNET_DNS_ANSWER_Subtype | ||
37 | { | ||
38 | /** | ||
39 | * Answers of this type contain a dns-packet that just has to be transmitted | ||
40 | */ | ||
41 | GNUNET_DNS_ANSWER_TYPE_IP, | ||
42 | |||
43 | /** | ||
44 | * Answers of this type contain an incomplete dns-packet. The IP-Address | ||
45 | * is all 0s. The addroffset points to it. | ||
46 | */ | ||
47 | GNUNET_DNS_ANSWER_TYPE_SERVICE, | ||
48 | |||
49 | /** | ||
50 | * Answers of this type contain an incomplete dns-packet as answer to a | ||
51 | * PTR-Query. The resolved name is not allocated. The addroffset points to it. | ||
52 | */ | ||
53 | GNUNET_DNS_ANSWER_TYPE_REV, | ||
54 | |||
55 | /** | ||
56 | * Answers of this type contains an IP6-Address but traffic to this IP should | ||
57 | * be routed through the GNUNet. | ||
58 | */ | ||
59 | GNUNET_DNS_ANSWER_TYPE_REMOTE_AAAA, | ||
60 | |||
61 | /** | ||
62 | * Answers of this type contains an IP4-Address but traffic to this IP should | ||
63 | * be routed through the GNUNet. | ||
64 | */ | ||
65 | GNUNET_DNS_ANSWER_TYPE_REMOTE_A | ||
66 | }; | ||
67 | |||
68 | struct GNUNET_vpn_service_descriptor | ||
69 | { | ||
70 | GNUNET_HashCode peer GNUNET_PACKED; | ||
71 | GNUNET_HashCode service_descriptor GNUNET_PACKED; | ||
72 | uint64_t ports GNUNET_PACKED; | ||
73 | uint32_t service_type GNUNET_PACKED; | ||
74 | }; | ||
75 | |||
76 | struct answer_packet | ||
77 | { | ||
78 | /* General data */ | ||
79 | struct GNUNET_MessageHeader hdr; | ||
80 | enum GNUNET_DNS_ANSWER_Subtype subtype GNUNET_PACKED; | ||
81 | |||
82 | char from[16]; | ||
83 | char to[16]; | ||
84 | char addrlen; | ||
85 | unsigned dst_port:16 GNUNET_PACKED; | ||
86 | /* -- */ | ||
87 | |||
88 | /* Data for GNUNET_DNS_ANSWER_TYPE_SERVICE */ | ||
89 | struct GNUNET_vpn_service_descriptor service_descr; | ||
90 | /* -- */ | ||
91 | |||
92 | /* Data for GNUNET_DNS_ANSWER_TYPE_REV */ | ||
93 | /* The offsett in octets from the beginning of the struct to the field | ||
94 | * in data where the IP-Address has to go. */ | ||
95 | uint16_t addroffset GNUNET_PACKED; | ||
96 | /* -- */ | ||
97 | |||
98 | /* Data for GNUNET_DNS_ANSWER_TYPE_REMOTE */ | ||
99 | /* either 4 or 16 */ | ||
100 | char addrsize; | ||
101 | unsigned char addr[16]; | ||
102 | /* -- */ | ||
103 | |||
104 | unsigned char data[1]; | ||
105 | }; | ||
106 | |||
107 | struct answer_packet_list | ||
108 | { | ||
109 | struct answer_packet_list *next GNUNET_PACKED; | ||
110 | struct answer_packet_list *prev GNUNET_PACKED; | ||
111 | struct GNUNET_SERVER_Client *client; | ||
112 | struct answer_packet pkt; | ||
113 | }; | ||
114 | GNUNET_NETWORK_STRUCT_END | ||
115 | |||
116 | #endif | ||
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 | ||