diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-15 10:52:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-15 10:52:06 +0000 |
commit | 3288af4a4651156c01bdf6ffe1b20c6fbedf4bd8 (patch) | |
tree | ed49951102400f7086f4db23846fb7aaf32e5eb1 /src/include | |
parent | 9e94c69b299f74ac88b14f92b7a01bba0c33a776 (diff) | |
download | gnunet-3288af4a4651156c01bdf6ffe1b20c6fbedf4bd8.tar.gz gnunet-3288af4a4651156c01bdf6ffe1b20c6fbedf4bd8.zip |
-eliminating duplicate struct definitions
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/Makefile.am | 1 | ||||
-rw-r--r-- | src/include/gns_protocol.h | 161 | ||||
-rw-r--r-- | src/include/gnunet_dnsparser_lib.h | 153 | ||||
-rw-r--r-- | src/include/gnunet_tun_lib.h | 396 |
4 files changed, 387 insertions, 324 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 63f7c3bb5..ee0ccc043 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -18,7 +18,6 @@ EXTRA_DIST = \ | |||
18 | 18 | ||
19 | gnunetinclude_HEADERS = \ | 19 | gnunetinclude_HEADERS = \ |
20 | platform.h plibc.h $(WINPROC) gettext.h \ | 20 | platform.h plibc.h $(WINPROC) gettext.h \ |
21 | gns_protocol.h \ | ||
22 | gnunet_applications.h \ | 21 | gnunet_applications.h \ |
23 | gnunet_arm_service.h \ | 22 | gnunet_arm_service.h \ |
24 | gnunet_ats_service.h \ | 23 | gnunet_ats_service.h \ |
diff --git a/src/include/gns_protocol.h b/src/include/gns_protocol.h deleted file mode 100644 index 0d9758bda..000000000 --- a/src/include/gns_protocol.h +++ /dev/null | |||
@@ -1,161 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 2, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file include/gns_protocol.h | ||
23 | * @brief Resource Record definitions | ||
24 | * @author Martin Schanzenbach | ||
25 | */ | ||
26 | #ifndef GNS_RECORDS_H | ||
27 | #define GNS_RECORDS_H | ||
28 | |||
29 | GNUNET_NETWORK_STRUCT_BEGIN | ||
30 | |||
31 | /** | ||
32 | * Payload of DNS SOA record (header). | ||
33 | */ | ||
34 | struct soa_data | ||
35 | { | ||
36 | /** | ||
37 | * The version number of the original copy of the zone. (NBO) | ||
38 | */ | ||
39 | uint32_t serial GNUNET_PACKED; | ||
40 | |||
41 | /** | ||
42 | * Time interval before the zone should be refreshed. (NBO) | ||
43 | */ | ||
44 | uint32_t refresh GNUNET_PACKED; | ||
45 | |||
46 | /** | ||
47 | * Time interval that should elapse before a failed refresh should | ||
48 | * be retried. (NBO) | ||
49 | */ | ||
50 | uint32_t retry GNUNET_PACKED; | ||
51 | |||
52 | /** | ||
53 | * Time value that specifies the upper limit on the time interval | ||
54 | * that can elapse before the zone is no longer authoritative. (NBO) | ||
55 | */ | ||
56 | uint32_t expire GNUNET_PACKED; | ||
57 | |||
58 | /** | ||
59 | * The bit minimum TTL field that should be exported with any RR | ||
60 | * from this zone. (NBO) | ||
61 | */ | ||
62 | uint32_t minimum GNUNET_PACKED; | ||
63 | }; | ||
64 | |||
65 | |||
66 | /** | ||
67 | * Payload of DNS SRV record (header). | ||
68 | */ | ||
69 | struct srv_data | ||
70 | { | ||
71 | |||
72 | /** | ||
73 | * Preference for this entry (lower value is higher preference). Clients | ||
74 | * will contact hosts from the lowest-priority group first and fall back | ||
75 | * to higher priorities if the low-priority entries are unavailable. (NBO) | ||
76 | */ | ||
77 | uint16_t prio GNUNET_PACKED; | ||
78 | |||
79 | /** | ||
80 | * Relative weight for records with the same priority. Clients will use | ||
81 | * the hosts of the same (lowest) priority with a probability proportional | ||
82 | * to the weight given. (NBO) | ||
83 | */ | ||
84 | uint16_t weight GNUNET_PACKED; | ||
85 | |||
86 | /** | ||
87 | * TCP or UDP port of the service. (NBO) | ||
88 | */ | ||
89 | uint16_t port GNUNET_PACKED; | ||
90 | |||
91 | /* followed by 'target' name */ | ||
92 | }; | ||
93 | |||
94 | |||
95 | /** | ||
96 | * Payload of DNSSEC TLSA record. | ||
97 | * http://datatracker.ietf.org/doc/draft-ietf-dane-protocol/ | ||
98 | */ | ||
99 | struct tlsa_data | ||
100 | { | ||
101 | |||
102 | /** | ||
103 | * Certificate usage | ||
104 | * 0: CA cert | ||
105 | * 1: Entity cert | ||
106 | * 2: Trust anchor | ||
107 | * 3: domain-issued cert | ||
108 | */ | ||
109 | uint8_t usage; | ||
110 | |||
111 | /** | ||
112 | * Selector | ||
113 | * What part will be matched against the cert | ||
114 | * presented by server | ||
115 | * 0: Full cert (in binary) | ||
116 | * 1: Full cert (in DER) | ||
117 | */ | ||
118 | uint8_t selector; | ||
119 | |||
120 | /** | ||
121 | * Matching type (of selected content) | ||
122 | * 0: exact match | ||
123 | * 1: SHA-256 hash | ||
124 | * 2: SHA-512 hash | ||
125 | */ | ||
126 | uint8_t matching_type; | ||
127 | |||
128 | /** | ||
129 | * followed by certificate association data | ||
130 | * The "certificate association data" to be matched. | ||
131 | * These bytes are either raw data (that is, the full certificate or | ||
132 | * its SubjectPublicKeyInfo, depending on the selector) for matching | ||
133 | * type 0, or the hash of the raw data for matching types 1 and 2. | ||
134 | * The data refers to the certificate in the association, not to the | ||
135 | * TLS ASN.1 Certificate object. | ||
136 | * | ||
137 | * The data is represented as a string of hex chars | ||
138 | */ | ||
139 | }; | ||
140 | |||
141 | /** | ||
142 | * Payload of GNS VPN record | ||
143 | */ | ||
144 | struct vpn_data | ||
145 | { | ||
146 | /** | ||
147 | * The peer to contact | ||
148 | */ | ||
149 | struct GNUNET_HashCode peer; | ||
150 | |||
151 | /** | ||
152 | * The protocol to use | ||
153 | */ | ||
154 | uint16_t proto; | ||
155 | |||
156 | /* followed by the servicename */ | ||
157 | }; | ||
158 | |||
159 | GNUNET_NETWORK_STRUCT_END | ||
160 | |||
161 | #endif | ||
diff --git a/src/include/gnunet_dnsparser_lib.h b/src/include/gnunet_dnsparser_lib.h index fb8f588bd..b4f33dd5a 100644 --- a/src/include/gnunet_dnsparser_lib.h +++ b/src/include/gnunet_dnsparser_lib.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2010, 2011, 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2010-2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -28,6 +28,7 @@ | |||
28 | #define GNUNET_DNSPARSER_LIB_H | 28 | #define GNUNET_DNSPARSER_LIB_H |
29 | 29 | ||
30 | #include "gnunet_common.h" | 30 | #include "gnunet_common.h" |
31 | #include "gnunet_tun_lib.h" | ||
31 | 32 | ||
32 | /** | 33 | /** |
33 | * Maximum length of a label in DNS. | 34 | * Maximum length of a label in DNS. |
@@ -54,150 +55,6 @@ | |||
54 | #define GNUNET_DNSPARSER_TYPE_SRV 33 | 55 | #define GNUNET_DNSPARSER_TYPE_SRV 33 |
55 | #define GNUNET_DNSPARSER_TYPE_TLSA 52 | 56 | #define GNUNET_DNSPARSER_TYPE_TLSA 52 |
56 | 57 | ||
57 | /** | ||
58 | * A few common DNS classes (ok, only one is common, but I list a | ||
59 | * couple more to make it clear what we're talking about here). | ||
60 | */ | ||
61 | #define GNUNET_DNSPARSER_CLASS_INTERNET 1 | ||
62 | #define GNUNET_DNSPARSER_CLASS_CHAOS 3 | ||
63 | #define GNUNET_DNSPARSER_CLASS_HESIOD 4 | ||
64 | |||
65 | #define GNUNET_DNSPARSER_OPCODE_QUERY 0 | ||
66 | #define GNUNET_DNSPARSER_OPCODE_INVERSE_QUERY 1 | ||
67 | #define GNUNET_DNSPARSER_OPCODE_STATUS 2 | ||
68 | |||
69 | /** | ||
70 | * RFC 1035 codes. | ||
71 | */ | ||
72 | #define GNUNET_DNSPARSER_RETURN_CODE_NO_ERROR 0 | ||
73 | #define GNUNET_DNSPARSER_RETURN_CODE_FORMAT_ERROR 1 | ||
74 | #define GNUNET_DNSPARSER_RETURN_CODE_SERVER_FAILURE 2 | ||
75 | #define GNUNET_DNSPARSER_RETURN_CODE_NAME_ERROR 3 | ||
76 | #define GNUNET_DNSPARSER_RETURN_CODE_NOT_IMPLEMENTED 4 | ||
77 | #define GNUNET_DNSPARSER_RETURN_CODE_REFUSED 5 | ||
78 | |||
79 | /** | ||
80 | * RFC 2136 codes | ||
81 | */ | ||
82 | #define GNUNET_DNSPARSER_RETURN_CODE_YXDOMAIN 6 | ||
83 | #define GNUNET_DNSPARSER_RETURN_CODE_YXRRSET 7 | ||
84 | #define GNUNET_DNSPARSER_RETURN_CODE_NXRRSET 8 | ||
85 | #define GNUNET_DNSPARSER_RETURN_CODE_NOT_AUTH 9 | ||
86 | #define GNUNET_DNSPARSER_RETURN_CODE_NOT_ZONE 10 | ||
87 | |||
88 | /** | ||
89 | * DNS flags (largely RFC 1035 / RFC 2136). | ||
90 | */ | ||
91 | struct GNUNET_DNSPARSER_Flags | ||
92 | { | ||
93 | #if __BYTE_ORDER == __LITTLE_ENDIAN | ||
94 | /** | ||
95 | * Set to 1 if recursion is desired (client -> server) | ||
96 | */ | ||
97 | unsigned int recursion_desired : 1 GNUNET_PACKED; | ||
98 | |||
99 | /** | ||
100 | * Set to 1 if message is truncated | ||
101 | */ | ||
102 | unsigned int message_truncated : 1 GNUNET_PACKED; | ||
103 | |||
104 | /** | ||
105 | * Set to 1 if this is an authoritative answer | ||
106 | */ | ||
107 | unsigned int authoritative_answer : 1 GNUNET_PACKED; | ||
108 | |||
109 | /** | ||
110 | * See GNUNET_DNSPARSER_OPCODE_ defines. | ||
111 | */ | ||
112 | unsigned int opcode : 4 GNUNET_PACKED; | ||
113 | |||
114 | /** | ||
115 | * query:0, response:1 | ||
116 | */ | ||
117 | unsigned int query_or_response : 1 GNUNET_PACKED; | ||
118 | |||
119 | /** | ||
120 | * See GNUNET_DNSPARSER_RETURN_CODE_ defines. | ||
121 | */ | ||
122 | unsigned int return_code : 4 GNUNET_PACKED; | ||
123 | |||
124 | /** | ||
125 | * See RFC 4035. | ||
126 | */ | ||
127 | unsigned int checking_disabled : 1 GNUNET_PACKED; | ||
128 | |||
129 | /** | ||
130 | * Response has been cryptographically verified, RFC 4035. | ||
131 | */ | ||
132 | unsigned int authenticated_data : 1 GNUNET_PACKED; | ||
133 | |||
134 | /** | ||
135 | * Always zero. | ||
136 | */ | ||
137 | unsigned int zero : 1 GNUNET_PACKED; | ||
138 | |||
139 | /** | ||
140 | * Set to 1 if recursion is available (server -> client) | ||
141 | */ | ||
142 | unsigned int recursion_available : 1 GNUNET_PACKED; | ||
143 | #elif __BYTE_ORDER == __BIG_ENDIAN | ||
144 | |||
145 | /** | ||
146 | * query:0, response:1 | ||
147 | */ | ||
148 | unsigned int query_or_response : 1 GNUNET_PACKED; | ||
149 | |||
150 | /** | ||
151 | * See GNUNET_DNSPARSER_OPCODE_ defines. | ||
152 | */ | ||
153 | unsigned int opcode : 4 GNUNET_PACKED; | ||
154 | |||
155 | /** | ||
156 | * Set to 1 if this is an authoritative answer | ||
157 | */ | ||
158 | unsigned int authoritative_answer : 1 GNUNET_PACKED; | ||
159 | |||
160 | /** | ||
161 | * Set to 1 if message is truncated | ||
162 | */ | ||
163 | unsigned int message_truncated : 1 GNUNET_PACKED; | ||
164 | |||
165 | /** | ||
166 | * Set to 1 if recursion is desired (client -> server) | ||
167 | */ | ||
168 | unsigned int recursion_desired : 1 GNUNET_PACKED; | ||
169 | |||
170 | |||
171 | /** | ||
172 | * Set to 1 if recursion is available (server -> client) | ||
173 | */ | ||
174 | unsigned int recursion_available : 1 GNUNET_PACKED; | ||
175 | |||
176 | /** | ||
177 | * Always zero. | ||
178 | */ | ||
179 | unsigned int zero : 1 GNUNET_PACKED; | ||
180 | |||
181 | /** | ||
182 | * Response has been cryptographically verified, RFC 4035. | ||
183 | */ | ||
184 | unsigned int authenticated_data : 1 GNUNET_PACKED; | ||
185 | |||
186 | /** | ||
187 | * See RFC 4035. | ||
188 | */ | ||
189 | unsigned int checking_disabled : 1 GNUNET_PACKED; | ||
190 | |||
191 | /** | ||
192 | * See GNUNET_DNSPARSER_RETURN_CODE_ defines. | ||
193 | */ | ||
194 | unsigned int return_code : 4 GNUNET_PACKED; | ||
195 | #else | ||
196 | #error byteorder undefined | ||
197 | #endif | ||
198 | |||
199 | } GNUNET_GCC_STRUCT_LAYOUT; | ||
200 | |||
201 | 58 | ||
202 | /** | 59 | /** |
203 | * A DNS query. | 60 | * A DNS query. |
@@ -220,7 +77,7 @@ struct GNUNET_DNSPARSER_Query | |||
220 | uint16_t type; | 77 | uint16_t type; |
221 | 78 | ||
222 | /** | 79 | /** |
223 | * See GNUNET_DNSPARSER_CLASS_*. | 80 | * See GNUNET_TUN_DNS_CLASS_*. |
224 | */ | 81 | */ |
225 | uint16_t class; | 82 | uint16_t class; |
226 | 83 | ||
@@ -459,7 +316,7 @@ struct GNUNET_DNSPARSER_Record | |||
459 | uint16_t type; | 316 | uint16_t type; |
460 | 317 | ||
461 | /** | 318 | /** |
462 | * See GNUNET_DNSPARSER_CLASS_*. | 319 | * See GNUNET_TUN_DNS_CLASS_*. |
463 | */ | 320 | */ |
464 | uint16_t class; | 321 | uint16_t class; |
465 | 322 | ||
@@ -514,7 +371,7 @@ struct GNUNET_DNSPARSER_Packet | |||
514 | /** | 371 | /** |
515 | * Bitfield of DNS flags. | 372 | * Bitfield of DNS flags. |
516 | */ | 373 | */ |
517 | struct GNUNET_DNSPARSER_Flags flags; | 374 | struct GNUNET_TUN_DnsFlags flags; |
518 | 375 | ||
519 | /** | 376 | /** |
520 | * DNS ID (to match replies to requests). | 377 | * DNS ID (to match replies to requests). |
diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h index 1b0bb716d..683910d93 100644 --- a/src/include/gnunet_tun_lib.h +++ b/src/include/gnunet_tun_lib.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2010, 2011, 2012 Christian Grothoff | 3 | (C) 2010-2013 Christian Grothoff |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -183,7 +183,14 @@ struct GNUNET_TUN_IPv6Header | |||
183 | */ | 183 | */ |
184 | struct GNUNET_TUN_TcpHeader | 184 | struct GNUNET_TUN_TcpHeader |
185 | { | 185 | { |
186 | /** | ||
187 | * Source port (in NBO). | ||
188 | */ | ||
186 | uint16_t source_port GNUNET_PACKED; | 189 | uint16_t source_port GNUNET_PACKED; |
190 | |||
191 | /** | ||
192 | * Destination port (in NBO). | ||
193 | */ | ||
187 | uint16_t destination_port GNUNET_PACKED; | 194 | uint16_t destination_port GNUNET_PACKED; |
188 | 195 | ||
189 | /** | 196 | /** |
@@ -244,26 +251,387 @@ struct GNUNET_TUN_TcpHeader | |||
244 | */ | 251 | */ |
245 | struct GNUNET_TUN_UdpHeader | 252 | struct GNUNET_TUN_UdpHeader |
246 | { | 253 | { |
254 | /** | ||
255 | * Source port (in NBO). | ||
256 | */ | ||
247 | uint16_t source_port GNUNET_PACKED; | 257 | uint16_t source_port GNUNET_PACKED; |
258 | |||
259 | /** | ||
260 | * Destination port (in NBO). | ||
261 | */ | ||
248 | uint16_t destination_port GNUNET_PACKED; | 262 | uint16_t destination_port GNUNET_PACKED; |
263 | |||
264 | /** | ||
265 | * Number of bytes of payload. | ||
266 | */ | ||
249 | uint16_t len GNUNET_PACKED; | 267 | uint16_t len GNUNET_PACKED; |
268 | |||
269 | /** | ||
270 | * Checksum. | ||
271 | */ | ||
250 | uint16_t crc GNUNET_PACKED; | 272 | uint16_t crc GNUNET_PACKED; |
251 | }; | 273 | }; |
252 | 274 | ||
253 | 275 | ||
276 | |||
277 | /** | ||
278 | * A few common DNS classes (ok, only one is common, but I list a | ||
279 | * couple more to make it clear what we're talking about here). | ||
280 | */ | ||
281 | #define GNUNET_TUN_DNS_CLASS_INTERNET 1 | ||
282 | #define GNUNET_TUN_DNS_CLASS_CHAOS 3 | ||
283 | #define GNUNET_TUN_DNS_CLASS_HESIOD 4 | ||
284 | |||
285 | #define GNUNET_TUN_DNS_OPCODE_QUERY 0 | ||
286 | #define GNUNET_TUN_DNS_OPCODE_INVERSE_QUERY 1 | ||
287 | #define GNUNET_TUN_DNS_OPCODE_STATUS 2 | ||
288 | |||
289 | |||
290 | /** | ||
291 | * RFC 1035 codes. | ||
292 | */ | ||
293 | #define GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR 0 | ||
294 | #define GNUNET_TUN_DNS_RETURN_CODE_FORMAT_ERROR 1 | ||
295 | #define GNUNET_TUN_DNS_RETURN_CODE_SERVER_FAILURE 2 | ||
296 | #define GNUNET_TUN_DNS_RETURN_CODE_NAME_ERROR 3 | ||
297 | #define GNUNET_TUN_DNS_RETURN_CODE_NOT_IMPLEMENTED 4 | ||
298 | #define GNUNET_TUN_DNS_RETURN_CODE_REFUSED 5 | ||
299 | |||
300 | /** | ||
301 | * RFC 2136 codes | ||
302 | */ | ||
303 | #define GNUNET_TUN_DNS_RETURN_CODE_YXDOMAIN 6 | ||
304 | #define GNUNET_TUN_DNS_RETURN_CODE_YXRRSET 7 | ||
305 | #define GNUNET_TUN_DNS_RETURN_CODE_NXRRSET 8 | ||
306 | #define GNUNET_TUN_DNS_RETURN_CODE_NOT_AUTH 9 | ||
307 | #define GNUNET_TUN_DNS_RETURN_CODE_NOT_ZONE 10 | ||
308 | |||
309 | |||
310 | /** | ||
311 | * DNS flags (largely RFC 1035 / RFC 2136). | ||
312 | */ | ||
313 | struct GNUNET_TUN_DnsFlags | ||
314 | { | ||
315 | #if __BYTE_ORDER == __LITTLE_ENDIAN | ||
316 | /** | ||
317 | * Set to 1 if recursion is desired (client -> server) | ||
318 | */ | ||
319 | unsigned int recursion_desired : 1 GNUNET_PACKED; | ||
320 | |||
321 | /** | ||
322 | * Set to 1 if message is truncated | ||
323 | */ | ||
324 | unsigned int message_truncated : 1 GNUNET_PACKED; | ||
325 | |||
326 | /** | ||
327 | * Set to 1 if this is an authoritative answer | ||
328 | */ | ||
329 | unsigned int authoritative_answer : 1 GNUNET_PACKED; | ||
330 | |||
331 | /** | ||
332 | * See GNUNET_TUN_DNS_OPCODE_ defines. | ||
333 | */ | ||
334 | unsigned int opcode : 4 GNUNET_PACKED; | ||
335 | |||
336 | /** | ||
337 | * query:0, response:1 | ||
338 | */ | ||
339 | unsigned int query_or_response : 1 GNUNET_PACKED; | ||
340 | |||
341 | /** | ||
342 | * See GNUNET_TUN_DNS_RETURN_CODE_ defines. | ||
343 | */ | ||
344 | unsigned int return_code : 4 GNUNET_PACKED; | ||
345 | |||
346 | /** | ||
347 | * See RFC 4035. | ||
348 | */ | ||
349 | unsigned int checking_disabled : 1 GNUNET_PACKED; | ||
350 | |||
351 | /** | ||
352 | * Response has been cryptographically verified, RFC 4035. | ||
353 | */ | ||
354 | unsigned int authenticated_data : 1 GNUNET_PACKED; | ||
355 | |||
356 | /** | ||
357 | * Always zero. | ||
358 | */ | ||
359 | unsigned int zero : 1 GNUNET_PACKED; | ||
360 | |||
361 | /** | ||
362 | * Set to 1 if recursion is available (server -> client) | ||
363 | */ | ||
364 | unsigned int recursion_available : 1 GNUNET_PACKED; | ||
365 | #elif __BYTE_ORDER == __BIG_ENDIAN | ||
366 | |||
367 | /** | ||
368 | * query:0, response:1 | ||
369 | */ | ||
370 | unsigned int query_or_response : 1 GNUNET_PACKED; | ||
371 | |||
372 | /** | ||
373 | * See GNUNET_TUN_DNS_OPCODE_ defines. | ||
374 | */ | ||
375 | unsigned int opcode : 4 GNUNET_PACKED; | ||
376 | |||
377 | /** | ||
378 | * Set to 1 if this is an authoritative answer | ||
379 | */ | ||
380 | unsigned int authoritative_answer : 1 GNUNET_PACKED; | ||
381 | |||
382 | /** | ||
383 | * Set to 1 if message is truncated | ||
384 | */ | ||
385 | unsigned int message_truncated : 1 GNUNET_PACKED; | ||
386 | |||
387 | /** | ||
388 | * Set to 1 if recursion is desired (client -> server) | ||
389 | */ | ||
390 | unsigned int recursion_desired : 1 GNUNET_PACKED; | ||
391 | |||
392 | |||
393 | /** | ||
394 | * Set to 1 if recursion is available (server -> client) | ||
395 | */ | ||
396 | unsigned int recursion_available : 1 GNUNET_PACKED; | ||
397 | |||
398 | /** | ||
399 | * Always zero. | ||
400 | */ | ||
401 | unsigned int zero : 1 GNUNET_PACKED; | ||
402 | |||
403 | /** | ||
404 | * Response has been cryptographically verified, RFC 4035. | ||
405 | */ | ||
406 | unsigned int authenticated_data : 1 GNUNET_PACKED; | ||
407 | |||
408 | /** | ||
409 | * See RFC 4035. | ||
410 | */ | ||
411 | unsigned int checking_disabled : 1 GNUNET_PACKED; | ||
412 | |||
413 | /** | ||
414 | * See GNUNET_TUN_DNS_RETURN_CODE_ defines. | ||
415 | */ | ||
416 | unsigned int return_code : 4 GNUNET_PACKED; | ||
417 | #else | ||
418 | #error byteorder undefined | ||
419 | #endif | ||
420 | |||
421 | } GNUNET_GCC_STRUCT_LAYOUT; | ||
422 | |||
423 | |||
424 | |||
254 | /** | 425 | /** |
255 | * DNS header. | 426 | * DNS header. |
256 | */ | 427 | */ |
257 | struct GNUNET_TUN_DnsHeader | 428 | struct GNUNET_TUN_DnsHeader |
258 | { | 429 | { |
430 | /** | ||
431 | * Unique identifier for the request/response. | ||
432 | */ | ||
259 | uint16_t id GNUNET_PACKED; | 433 | uint16_t id GNUNET_PACKED; |
260 | uint16_t flags GNUNET_PACKED; | 434 | |
261 | uint16_t qdcount GNUNET_PACKED; | 435 | /** |
262 | uint16_t ancount GNUNET_PACKED; | 436 | * Flags. |
263 | uint16_t nscount GNUNET_PACKED; | 437 | */ |
264 | uint16_t arcount GNUNET_PACKED; | 438 | struct GNUNET_TUN_DnsFlags flags; |
439 | |||
440 | /** | ||
441 | * Number of queries. | ||
442 | */ | ||
443 | uint16_t query_count GNUNET_PACKED; | ||
444 | |||
445 | /** | ||
446 | * Number of answers. | ||
447 | */ | ||
448 | uint16_t answer_rcount GNUNET_PACKED; | ||
449 | |||
450 | /** | ||
451 | * Number of authoritative answers. | ||
452 | */ | ||
453 | uint16_t authority_rcount GNUNET_PACKED; | ||
454 | |||
455 | /** | ||
456 | * Number of additional records. | ||
457 | */ | ||
458 | uint16_t additional_rcount GNUNET_PACKED; | ||
459 | }; | ||
460 | |||
461 | |||
462 | /** | ||
463 | * Payload of DNS SOA record (header). | ||
464 | */ | ||
465 | struct GNUNET_TUN_DnsSoaRecord | ||
466 | { | ||
467 | /** | ||
468 | * The version number of the original copy of the zone. (NBO) | ||
469 | */ | ||
470 | uint32_t serial GNUNET_PACKED; | ||
471 | |||
472 | /** | ||
473 | * Time interval before the zone should be refreshed. (NBO) | ||
474 | */ | ||
475 | uint32_t refresh GNUNET_PACKED; | ||
476 | |||
477 | /** | ||
478 | * Time interval that should elapse before a failed refresh should | ||
479 | * be retried. (NBO) | ||
480 | */ | ||
481 | uint32_t retry GNUNET_PACKED; | ||
482 | |||
483 | /** | ||
484 | * Time value that specifies the upper limit on the time interval | ||
485 | * that can elapse before the zone is no longer authoritative. (NBO) | ||
486 | */ | ||
487 | uint32_t expire GNUNET_PACKED; | ||
488 | |||
489 | /** | ||
490 | * The bit minimum TTL field that should be exported with any RR | ||
491 | * from this zone. (NBO) | ||
492 | */ | ||
493 | uint32_t minimum GNUNET_PACKED; | ||
265 | }; | 494 | }; |
266 | 495 | ||
496 | |||
497 | /** | ||
498 | * Payload of DNS SRV record (header). | ||
499 | */ | ||
500 | struct GNUNET_TUN_DnsSrvRecord | ||
501 | { | ||
502 | |||
503 | /** | ||
504 | * Preference for this entry (lower value is higher preference). Clients | ||
505 | * will contact hosts from the lowest-priority group first and fall back | ||
506 | * to higher priorities if the low-priority entries are unavailable. (NBO) | ||
507 | */ | ||
508 | uint16_t prio GNUNET_PACKED; | ||
509 | |||
510 | /** | ||
511 | * Relative weight for records with the same priority. Clients will use | ||
512 | * the hosts of the same (lowest) priority with a probability proportional | ||
513 | * to the weight given. (NBO) | ||
514 | */ | ||
515 | uint16_t weight GNUNET_PACKED; | ||
516 | |||
517 | /** | ||
518 | * TCP or UDP port of the service. (NBO) | ||
519 | */ | ||
520 | uint16_t port GNUNET_PACKED; | ||
521 | |||
522 | /* followed by 'target' name */ | ||
523 | }; | ||
524 | |||
525 | |||
526 | /** | ||
527 | * Payload of DNSSEC TLSA record. | ||
528 | * http://datatracker.ietf.org/doc/draft-ietf-dane-protocol/ | ||
529 | */ | ||
530 | struct GNUNET_TUN_DnsTlsaRecord | ||
531 | { | ||
532 | |||
533 | /** | ||
534 | * Certificate usage | ||
535 | * 0: CA cert | ||
536 | * 1: Entity cert | ||
537 | * 2: Trust anchor | ||
538 | * 3: domain-issued cert | ||
539 | */ | ||
540 | uint8_t usage; | ||
541 | |||
542 | /** | ||
543 | * Selector | ||
544 | * What part will be matched against the cert | ||
545 | * presented by server | ||
546 | * 0: Full cert (in binary) | ||
547 | * 1: Full cert (in DER) | ||
548 | */ | ||
549 | uint8_t selector; | ||
550 | |||
551 | /** | ||
552 | * Matching type (of selected content) | ||
553 | * 0: exact match | ||
554 | * 1: SHA-256 hash | ||
555 | * 2: SHA-512 hash | ||
556 | */ | ||
557 | uint8_t matching_type; | ||
558 | |||
559 | /** | ||
560 | * followed by certificate association data | ||
561 | * The "certificate association data" to be matched. | ||
562 | * These bytes are either raw data (that is, the full certificate or | ||
563 | * its SubjectPublicKeyInfo, depending on the selector) for matching | ||
564 | * type 0, or the hash of the raw data for matching types 1 and 2. | ||
565 | * The data refers to the certificate in the association, not to the | ||
566 | * TLS ASN.1 Certificate object. | ||
567 | * | ||
568 | * The data is represented as a string of hex chars | ||
569 | */ | ||
570 | }; | ||
571 | |||
572 | |||
573 | /** | ||
574 | * Payload of GNS VPN record | ||
575 | */ | ||
576 | struct GNUNET_TUN_GnsVpnRecord | ||
577 | { | ||
578 | /** | ||
579 | * The peer to contact | ||
580 | */ | ||
581 | struct GNUNET_HashCode peer; | ||
582 | |||
583 | /** | ||
584 | * The protocol to use | ||
585 | */ | ||
586 | uint16_t proto; | ||
587 | |||
588 | /* followed by the servicename */ | ||
589 | }; | ||
590 | |||
591 | /** | ||
592 | * DNS query prefix. | ||
593 | */ | ||
594 | struct GNUNET_TUN_DnsQueryLine | ||
595 | { | ||
596 | /** | ||
597 | * Desired type (GNUNET_DNSPARSER_TYPE_XXX). (NBO) | ||
598 | */ | ||
599 | uint16_t type GNUNET_PACKED; | ||
600 | |||
601 | /** | ||
602 | * Desired class (usually GNUNET_TUN_DNS_CLASS_INTERNET). (NBO) | ||
603 | */ | ||
604 | uint16_t class GNUNET_PACKED; | ||
605 | }; | ||
606 | |||
607 | |||
608 | /** | ||
609 | * General DNS record prefix. | ||
610 | */ | ||
611 | struct GNUNET_TUN_DnsRecordLine | ||
612 | { | ||
613 | /** | ||
614 | * Record type (GNUNET_DNSPARSER_TYPE_XXX). (NBO) | ||
615 | */ | ||
616 | uint16_t type GNUNET_PACKED; | ||
617 | |||
618 | /** | ||
619 | * Record class (usually GNUNET_TUN_DNS_CLASS_INTERNET). (NBO) | ||
620 | */ | ||
621 | uint16_t class GNUNET_PACKED; | ||
622 | |||
623 | /** | ||
624 | * Expiration for the record (in seconds). (NBO) | ||
625 | */ | ||
626 | uint32_t ttl GNUNET_PACKED; | ||
627 | |||
628 | /** | ||
629 | * Number of bytes of data that follow. (NBO) | ||
630 | */ | ||
631 | uint16_t data_len GNUNET_PACKED; | ||
632 | }; | ||
633 | |||
634 | |||
267 | #define GNUNET_TUN_ICMPTYPE_ECHO_REPLY 0 | 635 | #define GNUNET_TUN_ICMPTYPE_ECHO_REPLY 0 |
268 | #define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE 3 | 636 | #define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE 3 |
269 | #define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH 4 | 637 | #define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH 4 |
@@ -364,7 +732,7 @@ GNUNET_TUN_initialize_ipv6_header (struct GNUNET_TUN_IPv6Header *ip, | |||
364 | * @param ip ipv4 header fully initialized | 732 | * @param ip ipv4 header fully initialized |
365 | * @param tcp TCP header (initialized except for CRC) | 733 | * @param tcp TCP header (initialized except for CRC) |
366 | * @param payload the TCP payload | 734 | * @param payload the TCP payload |
367 | * @param payload_length number of bytes of TCP payload | 735 | * @param payload_length number of bytes of TCP @a payload |
368 | */ | 736 | */ |
369 | void | 737 | void |
370 | GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, | 738 | GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, |
@@ -392,7 +760,7 @@ GNUNET_TUN_calculate_tcp6_checksum (const struct GNUNET_TUN_IPv6Header *ip, | |||
392 | * @param ip ipv4 header fully initialized | 760 | * @param ip ipv4 header fully initialized |
393 | * @param udp UDP header (initialized except for CRC) | 761 | * @param udp UDP header (initialized except for CRC) |
394 | * @param payload the UDP payload | 762 | * @param payload the UDP payload |
395 | * @param payload_length number of bytes of UDP payload | 763 | * @param payload_length number of bytes of UDP @a payload |
396 | */ | 764 | */ |
397 | void | 765 | void |
398 | GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, | 766 | GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, |
@@ -430,11 +798,11 @@ GNUNET_TUN_calculate_icmp_checksum (struct GNUNET_TUN_IcmpHeader *icmp, | |||
430 | 798 | ||
431 | 799 | ||
432 | /** | 800 | /** |
433 | * Create a regex in 'rxstr' from the given 'ip' and 'netmask'. | 801 | * Create a regex in @a rxstr from the given @a ip and @a netmask. |
434 | * | 802 | * |
435 | * @param ip IPv4 representation. | 803 | * @param ip IPv4 representation. |
436 | * @param netmask netmask for the ip. | 804 | * @param netmask netmask for the ip. |
437 | * @param rxstr generated regex, must be at least GNUNET_REGEX_IPV4_REGEXLEN | 805 | * @param rxstr generated regex, must be at least #GNUNET_REGEX_IPV4_REGEXLEN |
438 | * bytes long. | 806 | * bytes long. |
439 | */ | 807 | */ |
440 | void | 808 | void |
@@ -443,11 +811,11 @@ GNUNET_TUN_ipv4toregexsearch (const struct in_addr *ip, const char *netmask, | |||
443 | 811 | ||
444 | 812 | ||
445 | /** | 813 | /** |
446 | * Create a regex in 'rxstr' from the given 'ipv6' and 'prefixlen'. | 814 | * Create a regex in @a rxstr from the given @a ipv6 and @a prefixlen. |
447 | * | 815 | * |
448 | * @param ipv6 IPv6 representation. | 816 | * @param ipv6 IPv6 representation. |
449 | * @param prefixlen length of the ipv6 prefix. | 817 | * @param prefixlen length of the ipv6 prefix. |
450 | * @param rxstr generated regex, must be at least GNUNET_REGEX_IPV6_REGEXLEN | 818 | * @param rxstr generated regex, must be at least #GNUNET_REGEX_IPV6_REGEXLEN |
451 | * bytes long. | 819 | * bytes long. |
452 | */ | 820 | */ |
453 | void | 821 | void |
@@ -459,7 +827,7 @@ GNUNET_TUN_ipv6toregexsearch (const struct in6_addr *ipv6, | |||
459 | * Convert an exit policy to a regular expression. The exit policy | 827 | * Convert an exit policy to a regular expression. The exit policy |
460 | * specifies a set of subnets this peer is willing to serve as an | 828 | * specifies a set of subnets this peer is willing to serve as an |
461 | * exit for; the resulting regular expression will match the | 829 | * exit for; the resulting regular expression will match the |
462 | * IPv6 address strings as returned by 'GNUNET_TUN_ipv6toregexsearch'. | 830 | * IPv6 address strings as returned by #GNUNET_TUN_ipv6toregexsearch. |
463 | * | 831 | * |
464 | * @param policy exit policy specification | 832 | * @param policy exit policy specification |
465 | * @return regular expression, NULL on error | 833 | * @return regular expression, NULL on error |
@@ -472,7 +840,7 @@ GNUNET_TUN_ipv6policy2regex (const char *policy); | |||
472 | * Convert an exit policy to a regular expression. The exit policy | 840 | * Convert an exit policy to a regular expression. The exit policy |
473 | * specifies a set of subnets this peer is willing to serve as an | 841 | * specifies a set of subnets this peer is willing to serve as an |
474 | * exit for; the resulting regular expression will match the | 842 | * exit for; the resulting regular expression will match the |
475 | * IPv4 address strings as returned by 'GNUNET_TUN_ipv4toregexsearch'. | 843 | * IPv4 address strings as returned by #GNUNET_TUN_ipv4toregexsearch. |
476 | * | 844 | * |
477 | * @param policy exit policy specification | 845 | * @param policy exit policy specification |
478 | * @return regular expression, NULL on error | 846 | * @return regular expression, NULL on error |