aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-15 10:52:06 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-15 10:52:06 +0000
commit3288af4a4651156c01bdf6ffe1b20c6fbedf4bd8 (patch)
treeed49951102400f7086f4db23846fb7aaf32e5eb1
parent9e94c69b299f74ac88b14f92b7a01bba0c33a776 (diff)
downloadgnunet-3288af4a4651156c01bdf6ffe1b20c6fbedf4bd8.tar.gz
gnunet-3288af4a4651156c01bdf6ffe1b20c6fbedf4bd8.zip
-eliminating duplicate struct definitions
-rw-r--r--src/dns/Makefile.am2
-rw-r--r--src/dns/dnsparser.c50
-rw-r--r--src/dns/dnsparser.h195
-rw-r--r--src/dns/gnunet-dns-monitor.c6
-rw-r--r--src/dns/gnunet-service-dns.c2
-rw-r--r--src/gns/gnunet-dns2gns.c10
-rw-r--r--src/gns/gnunet-service-gns_interceptor.c8
-rw-r--r--src/gns/gnunet-service-gns_resolver.c36
-rw-r--r--src/gns/test_gns_simple_srv_lookup.c6
-rw-r--r--src/include/Makefile.am1
-rw-r--r--src/include/gns_protocol.h161
-rw-r--r--src/include/gnunet_dnsparser_lib.h153
-rw-r--r--src/include/gnunet_tun_lib.h396
-rw-r--r--src/namestore/namestore_api_common.c37
14 files changed, 464 insertions, 599 deletions
diff --git a/src/dns/Makefile.am b/src/dns/Makefile.am
index 345c1316c..441ffeefd 100644
--- a/src/dns/Makefile.am
+++ b/src/dns/Makefile.am
@@ -82,7 +82,7 @@ gnunet_service_dns_DEPENDENCIES = \
82 libgnunetdnsstub.la 82 libgnunetdnsstub.la
83 83
84libgnunetdnsparser_la_SOURCES = \ 84libgnunetdnsparser_la_SOURCES = \
85 dnsparser.c dnsparser.h 85 dnsparser.c
86libgnunetdnsparser_la_LIBADD = \ 86libgnunetdnsparser_la_LIBADD = \
87 $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \ 87 $(top_builddir)/src/util/libgnunetutil.la $(XLIB) \
88 -lidn 88 -lidn
diff --git a/src/dns/dnsparser.c b/src/dns/dnsparser.c
index 18ef4c219..68b882279 100644
--- a/src/dns/dnsparser.c
+++ b/src/dns/dnsparser.c
@@ -31,7 +31,7 @@
31#endif 31#endif
32#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
33#include "gnunet_dnsparser_lib.h" 33#include "gnunet_dnsparser_lib.h"
34#include "dnsparser.h" 34#include "gnunet_tun_lib.h"
35 35
36 36
37/** 37/**
@@ -235,7 +235,7 @@ parse_query (const char *udp_payload,
235 struct GNUNET_DNSPARSER_Query *q) 235 struct GNUNET_DNSPARSER_Query *q)
236{ 236{
237 char *name; 237 char *name;
238 struct query_line ql; 238 struct GNUNET_TUN_DnsQueryLine ql;
239 239
240 name = parse_name (udp_payload, 240 name = parse_name (udp_payload,
241 udp_payload_length, 241 udp_payload_length,
@@ -243,7 +243,7 @@ parse_query (const char *udp_payload,
243 if (NULL == name) 243 if (NULL == name)
244 return GNUNET_SYSERR; 244 return GNUNET_SYSERR;
245 q->name = name; 245 q->name = name;
246 if (*off + sizeof (struct query_line) > udp_payload_length) 246 if (*off + sizeof (struct GNUNET_TUN_DnsQueryLine) > udp_payload_length)
247 return GNUNET_SYSERR; 247 return GNUNET_SYSERR;
248 memcpy (&ql, &udp_payload[*off], sizeof (ql)); 248 memcpy (&ql, &udp_payload[*off], sizeof (ql));
249 *off += sizeof (ql); 249 *off += sizeof (ql);
@@ -270,12 +270,12 @@ parse_record (const char *udp_payload,
270 struct GNUNET_DNSPARSER_Record *r) 270 struct GNUNET_DNSPARSER_Record *r)
271{ 271{
272 char *name; 272 char *name;
273 struct record_line rl; 273 struct GNUNET_TUN_DnsRecordLine rl;
274 size_t old_off; 274 size_t old_off;
275 struct soa_data soa; 275 struct GNUNET_TUN_DnsSoaRecord soa;
276 uint16_t mxpref; 276 uint16_t mxpref;
277 uint16_t data_len; 277 uint16_t data_len;
278 struct srv_data srv; 278 struct GNUNET_TUN_DnsSrvRecord srv;
279 char *ndup; 279 char *ndup;
280 char *tok; 280 char *tok;
281 281
@@ -285,7 +285,7 @@ parse_record (const char *udp_payload,
285 if (NULL == name) 285 if (NULL == name)
286 return GNUNET_SYSERR; 286 return GNUNET_SYSERR;
287 r->name = name; 287 r->name = name;
288 if (*off + sizeof (struct record_line) > udp_payload_length) 288 if (*off + sizeof (struct GNUNET_TUN_DnsRecordLine) > udp_payload_length)
289 return GNUNET_SYSERR; 289 return GNUNET_SYSERR;
290 memcpy (&rl, &udp_payload[*off], sizeof (rl)); 290 memcpy (&rl, &udp_payload[*off], sizeof (rl));
291 (*off) += sizeof (rl); 291 (*off) += sizeof (rl);
@@ -320,15 +320,15 @@ parse_record (const char *udp_payload,
320 off, 0); 320 off, 0);
321 if ( (NULL == r->data.soa->mname) || 321 if ( (NULL == r->data.soa->mname) ||
322 (NULL == r->data.soa->rname) || 322 (NULL == r->data.soa->rname) ||
323 (*off + sizeof (struct soa_data) > udp_payload_length) ) 323 (*off + sizeof (struct GNUNET_TUN_DnsSoaRecord) > udp_payload_length) )
324 return GNUNET_SYSERR; 324 return GNUNET_SYSERR;
325 memcpy (&soa, &udp_payload[*off], sizeof (struct soa_data)); 325 memcpy (&soa, &udp_payload[*off], sizeof (struct GNUNET_TUN_DnsSoaRecord));
326 r->data.soa->serial = ntohl (soa.serial); 326 r->data.soa->serial = ntohl (soa.serial);
327 r->data.soa->refresh = ntohl (soa.refresh); 327 r->data.soa->refresh = ntohl (soa.refresh);
328 r->data.soa->retry = ntohl (soa.retry); 328 r->data.soa->retry = ntohl (soa.retry);
329 r->data.soa->expire = ntohl (soa.expire); 329 r->data.soa->expire = ntohl (soa.expire);
330 r->data.soa->minimum_ttl = ntohl (soa.minimum); 330 r->data.soa->minimum_ttl = ntohl (soa.minimum);
331 (*off) += sizeof (struct soa_data); 331 (*off) += sizeof (struct GNUNET_TUN_DnsSoaRecord);
332 if (old_off + data_len != *off) 332 if (old_off + data_len != *off)
333 return GNUNET_SYSERR; 333 return GNUNET_SYSERR;
334 return GNUNET_OK; 334 return GNUNET_OK;
@@ -352,10 +352,10 @@ parse_record (const char *udp_payload,
352 if (NULL == strstr (r->name, "._")) 352 if (NULL == strstr (r->name, "._"))
353 return GNUNET_SYSERR; /* necessary string from "._$PROTO" not present */ 353 return GNUNET_SYSERR; /* necessary string from "._$PROTO" not present */
354 old_off = *off; 354 old_off = *off;
355 if (*off + sizeof (struct srv_data) > udp_payload_length) 355 if (*off + sizeof (struct GNUNET_TUN_DnsSrvRecord) > udp_payload_length)
356 return GNUNET_SYSERR; 356 return GNUNET_SYSERR;
357 memcpy (&srv, &udp_payload[*off], sizeof (struct srv_data)); 357 memcpy (&srv, &udp_payload[*off], sizeof (struct GNUNET_TUN_DnsSrvRecord));
358 (*off) += sizeof (struct srv_data); 358 (*off) += sizeof (struct GNUNET_TUN_DnsSrvRecord);
359 r->data.srv = GNUNET_malloc (sizeof (struct GNUNET_DNSPARSER_SrvRecord)); 359 r->data.srv = GNUNET_malloc (sizeof (struct GNUNET_DNSPARSER_SrvRecord));
360 r->data.srv->priority = ntohs (srv.prio); 360 r->data.srv->priority = ntohs (srv.prio);
361 r->data.srv->weight = ntohs (srv.weight); 361 r->data.srv->weight = ntohs (srv.weight);
@@ -685,9 +685,9 @@ add_query (char *dst,
685 const struct GNUNET_DNSPARSER_Query *query) 685 const struct GNUNET_DNSPARSER_Query *query)
686{ 686{
687 int ret; 687 int ret;
688 struct query_line ql; 688 struct GNUNET_TUN_DnsQueryLine ql;
689 689
690 ret = add_name (dst, dst_len - sizeof (struct query_line), off, query->name); 690 ret = add_name (dst, dst_len - sizeof (struct GNUNET_TUN_DnsQueryLine), off, query->name);
691 if (ret != GNUNET_OK) 691 if (ret != GNUNET_OK)
692 return ret; 692 return ret;
693 ql.type = htons (query->type); 693 ql.type = htons (query->type);
@@ -745,7 +745,7 @@ add_soa (char *dst,
745 size_t *off, 745 size_t *off,
746 const struct GNUNET_DNSPARSER_SoaRecord *soa) 746 const struct GNUNET_DNSPARSER_SoaRecord *soa)
747{ 747{
748 struct soa_data sd; 748 struct GNUNET_TUN_DnsSoaRecord sd;
749 int ret; 749 int ret;
750 750
751 if ( (GNUNET_OK != (ret = add_name (dst, 751 if ( (GNUNET_OK != (ret = add_name (dst,
@@ -757,7 +757,7 @@ add_soa (char *dst,
757 off, 757 off,
758 soa->rname)) ) ) 758 soa->rname)) ) )
759 return ret; 759 return ret;
760 if (*off + sizeof (struct soa_data) > dst_len) 760 if (*off + sizeof (struct GNUNET_TUN_DnsSoaRecord) > dst_len)
761 return GNUNET_NO; 761 return GNUNET_NO;
762 sd.serial = htonl (soa->serial); 762 sd.serial = htonl (soa->serial);
763 sd.refresh = htonl (soa->refresh); 763 sd.refresh = htonl (soa->refresh);
@@ -788,10 +788,10 @@ add_srv (char *dst,
788 size_t *off, 788 size_t *off,
789 const struct GNUNET_DNSPARSER_SrvRecord *srv) 789 const struct GNUNET_DNSPARSER_SrvRecord *srv)
790{ 790{
791 struct srv_data sd; 791 struct GNUNET_TUN_DnsSrvRecord sd;
792 int ret; 792 int ret;
793 793
794 if (*off + sizeof (struct srv_data) > dst_len) 794 if (*off + sizeof (struct GNUNET_TUN_DnsSrvRecord) > dst_len)
795 return GNUNET_NO; 795 return GNUNET_NO;
796 sd.prio = htons (srv->priority); 796 sd.prio = htons (srv->priority);
797 sd.weight = htons (srv->weight); 797 sd.weight = htons (srv->weight);
@@ -828,7 +828,7 @@ add_record (char *dst,
828 int ret; 828 int ret;
829 size_t start; 829 size_t start;
830 size_t pos; 830 size_t pos;
831 struct record_line rl; 831 struct GNUNET_TUN_DnsRecordLine rl;
832 char *name; 832 char *name;
833 833
834 start = *off; 834 start = *off;
@@ -842,14 +842,14 @@ add_record (char *dst,
842 record->data.srv->service, 842 record->data.srv->service,
843 record->data.srv->proto, 843 record->data.srv->proto,
844 record->data.srv->domain_name); 844 record->data.srv->domain_name);
845 ret = add_name (dst, dst_len - sizeof (struct record_line), off, name); 845 ret = add_name (dst, dst_len - sizeof (struct GNUNET_TUN_DnsRecordLine), off, name);
846 if (name != record->name) 846 if (name != record->name)
847 GNUNET_free (name); 847 GNUNET_free (name);
848 if (GNUNET_OK != ret) 848 if (GNUNET_OK != ret)
849 return ret; 849 return ret;
850 /* '*off' is now the position where we will need to write the record line */ 850 /* '*off' is now the position where we will need to write the record line */
851 851
852 pos = *off + sizeof (struct record_line); 852 pos = *off + sizeof (struct GNUNET_TUN_DnsRecordLine);
853 switch (record->type) 853 switch (record->type)
854 { 854 {
855 case GNUNET_DNSPARSER_TYPE_MX: 855 case GNUNET_DNSPARSER_TYPE_MX:
@@ -883,7 +883,7 @@ add_record (char *dst,
883 return GNUNET_NO; 883 return GNUNET_NO;
884 } 884 }
885 885
886 if (pos - (*off + sizeof (struct record_line)) > UINT16_MAX) 886 if (pos - (*off + sizeof (struct GNUNET_TUN_DnsRecordLine)) > UINT16_MAX)
887 { 887 {
888 /* record data too long */ 888 /* record data too long */
889 *off = start; 889 *off = start;
@@ -892,8 +892,8 @@ add_record (char *dst,
892 rl.type = htons (record->type); 892 rl.type = htons (record->type);
893 rl.class = htons (record->class); 893 rl.class = htons (record->class);
894 rl.ttl = htonl (GNUNET_TIME_absolute_get_remaining (record->expiration_time).rel_value_us / 1000LL / 1000LL); /* in seconds */ 894 rl.ttl = htonl (GNUNET_TIME_absolute_get_remaining (record->expiration_time).rel_value_us / 1000LL / 1000LL); /* in seconds */
895 rl.data_len = htons ((uint16_t) (pos - (*off + sizeof (struct record_line)))); 895 rl.data_len = htons ((uint16_t) (pos - (*off + sizeof (struct GNUNET_TUN_DnsRecordLine))));
896 memcpy (&dst[*off], &rl, sizeof (struct record_line)); 896 memcpy (&dst[*off], &rl, sizeof (struct GNUNET_TUN_DnsRecordLine));
897 *off = pos; 897 *off = pos;
898 return GNUNET_OK; 898 return GNUNET_OK;
899} 899}
diff --git a/src/dns/dnsparser.h b/src/dns/dnsparser.h
deleted file mode 100644
index d312f8931..000000000
--- a/src/dns/dnsparser.h
+++ /dev/null
@@ -1,195 +0,0 @@
1/*
2 This file is part of GNUnet
3 (C) 2010, 2011, 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 dns/dnsparser.h
23 * @brief helper library to parse DNS packets.
24 * @author Philipp Toelke
25 * @author Christian Grothoff
26 * @author Martin Schanzenbach
27 */
28GNUNET_NETWORK_STRUCT_BEGIN
29
30/* FIXME: replace this one with the one from tcpip_tun.h!? */
31/**
32 * Head of a any DNS message.
33 */
34struct GNUNET_TUN_DnsHeader
35{
36 /**
37 * Request/response ID. (NBO)
38 */
39 uint16_t id GNUNET_PACKED;
40
41 /**
42 * Flags for the operation.
43 */
44 struct GNUNET_DNSPARSER_Flags flags;
45
46 /**
47 * number of questions (NBO)
48 */
49 uint16_t query_count GNUNET_PACKED;
50
51 /**
52 * number of answers (NBO)
53 */
54 uint16_t answer_rcount GNUNET_PACKED;
55
56 /**
57 * number of authority-records (NBO)
58 */
59 uint16_t authority_rcount GNUNET_PACKED;
60
61 /**
62 * number of additional records (NBO)
63 */
64 uint16_t additional_rcount GNUNET_PACKED;
65};
66
67
68/**
69 * DNS query prefix.
70 */
71struct query_line
72{
73 /**
74 * Desired type (GNUNET_DNSPARSER_TYPE_XXX). (NBO)
75 */
76 uint16_t type GNUNET_PACKED;
77
78 /**
79 * Desired class (usually GNUNET_DNSPARSER_CLASS_INTERNET). (NBO)
80 */
81 uint16_t class GNUNET_PACKED;
82};
83
84
85/**
86 * General DNS record prefix.
87 */
88struct record_line
89{
90 /**
91 * Record type (GNUNET_DNSPARSER_TYPE_XXX). (NBO)
92 */
93 uint16_t type GNUNET_PACKED;
94
95 /**
96 * Record class (usually GNUNET_DNSPARSER_CLASS_INTERNET). (NBO)
97 */
98 uint16_t class GNUNET_PACKED;
99
100 /**
101 * Expiration for the record (in seconds). (NBO)
102 */
103 uint32_t ttl GNUNET_PACKED;
104
105 /**
106 * Number of bytes of data that follow. (NBO)
107 */
108 uint16_t data_len GNUNET_PACKED;
109};
110
111
112/**
113 * Payload of DNS SOA record (header).
114 */
115struct soa_data
116{
117 /**
118 * The version number of the original copy of the zone. (NBO)
119 */
120 uint32_t serial GNUNET_PACKED;
121
122 /**
123 * Time interval before the zone should be refreshed. (NBO)
124 */
125 uint32_t refresh GNUNET_PACKED;
126
127 /**
128 * Time interval that should elapse before a failed refresh should
129 * be retried. (NBO)
130 */
131 uint32_t retry GNUNET_PACKED;
132
133 /**
134 * Time value that specifies the upper limit on the time interval
135 * that can elapse before the zone is no longer authoritative. (NBO)
136 */
137 uint32_t expire GNUNET_PACKED;
138
139 /**
140 * The bit minimum TTL field that should be exported with any RR
141 * from this zone. (NBO)
142 */
143 uint32_t minimum GNUNET_PACKED;
144};
145
146
147/**
148 * Payload of DNS SRV record (header).
149 */
150struct srv_data
151{
152
153 /**
154 * Preference for this entry (lower value is higher preference). Clients
155 * will contact hosts from the lowest-priority group first and fall back
156 * to higher priorities if the low-priority entries are unavailable. (NBO)
157 */
158 uint16_t prio GNUNET_PACKED;
159
160 /**
161 * Relative weight for records with the same priority. Clients will use
162 * the hosts of the same (lowest) priority with a probability proportional
163 * to the weight given. (NBO)
164 */
165 uint16_t weight GNUNET_PACKED;
166
167 /**
168 * TCP or UDP port of the service. (NBO)
169 */
170 uint16_t port GNUNET_PACKED;
171
172 /* followed by 'target' name */
173};
174
175
176/**
177 * Payload of GNS VPN record
178 */
179struct vpn_data
180{
181 /**
182 * The peer to contact
183 */
184 struct GNUNET_HashCode peer;
185
186 /**
187 * The protocol to use
188 */
189 uint16_t proto GNUNET_PACKED;
190
191
192 /* followed by the servicename / identifier / password (0-terminated) */
193};
194
195GNUNET_NETWORK_STRUCT_END
diff --git a/src/dns/gnunet-dns-monitor.c b/src/dns/gnunet-dns-monitor.c
index ece96db71..ed09d49b1 100644
--- a/src/dns/gnunet-dns-monitor.c
+++ b/src/dns/gnunet-dns-monitor.c
@@ -94,9 +94,9 @@ get_class (uint16_t class)
94 static char buf[6]; 94 static char buf[6];
95 switch (class) 95 switch (class)
96 { 96 {
97 case GNUNET_DNSPARSER_CLASS_INTERNET: return "IN"; 97 case GNUNET_TUN_DNS_CLASS_INTERNET: return "IN";
98 case GNUNET_DNSPARSER_CLASS_CHAOS: return "CHAOS"; 98 case GNUNET_TUN_DNS_CLASS_CHAOS: return "CHAOS";
99 case GNUNET_DNSPARSER_CLASS_HESIOD: return "HESIOD"; 99 case GNUNET_TUN_DNS_CLASS_HESIOD: return "HESIOD";
100 } 100 }
101 GNUNET_snprintf (buf, sizeof (buf), "%u", (unsigned int) class); 101 GNUNET_snprintf (buf, sizeof (buf), "%u", (unsigned int) class);
102 return buf; 102 return buf;
diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c
index 4a94283ab..ac410d3ed 100644
--- a/src/dns/gnunet-service-dns.c
+++ b/src/dns/gnunet-service-dns.c
@@ -835,7 +835,7 @@ handle_client_response (void *cls GNUNET_UNUSED,
835 /* if query changed to answer, move past DNS resolution phase... */ 835 /* if query changed to answer, move past DNS resolution phase... */
836 if ( (RP_QUERY == rr->phase) && 836 if ( (RP_QUERY == rr->phase) &&
837 (rr->payload_length > sizeof (struct GNUNET_TUN_DnsHeader)) && 837 (rr->payload_length > sizeof (struct GNUNET_TUN_DnsHeader)) &&
838 ((struct GNUNET_DNSPARSER_Flags*)&(((struct GNUNET_TUN_DnsHeader*) rr->payload)->flags))->query_or_response == 1) 838 ((struct GNUNET_TUN_DnsFlags*)&(((struct GNUNET_TUN_DnsHeader*) rr->payload)->flags))->query_or_response == 1)
839 { 839 {
840 rr->phase = RP_INTERNET_DNS; 840 rr->phase = RP_INTERNET_DNS;
841 GNUNET_array_grow (rr->client_wait_list, 841 GNUNET_array_grow (rr->client_wait_list,
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index 99ee81fad..fc78a5050 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -281,14 +281,14 @@ result_processor (void *cls,
281 request->lookup = NULL; 281 request->lookup = NULL;
282 packet = request->packet; 282 packet = request->packet;
283 packet->flags.query_or_response = 1; 283 packet->flags.query_or_response = 1;
284 packet->flags.return_code = GNUNET_DNSPARSER_RETURN_CODE_NO_ERROR; 284 packet->flags.return_code = GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR;
285 packet->flags.checking_disabled = 0; 285 packet->flags.checking_disabled = 0;
286 packet->flags.authenticated_data = 1; 286 packet->flags.authenticated_data = 1;
287 packet->flags.zero = 0; 287 packet->flags.zero = 0;
288 packet->flags.recursion_available = 1; 288 packet->flags.recursion_available = 1;
289 packet->flags.message_truncated = 0; 289 packet->flags.message_truncated = 0;
290 packet->flags.authoritative_answer = 0; 290 packet->flags.authoritative_answer = 0;
291 //packet->flags.opcode = GNUNET_DNSPARSER_OPCODE_STATUS; // ??? 291 //packet->flags.opcode = GNUNET_TUN_DNS_OPCODE_STATUS; // ???
292 for (i=0;i<rd_count;i++) 292 for (i=0;i<rd_count;i++)
293 { 293 {
294 rec.expiration_time.abs_value_us = rd[i].expiration_time; 294 rec.expiration_time.abs_value_us = rd[i].expiration_time;
@@ -297,7 +297,7 @@ result_processor (void *cls,
297 case GNUNET_DNSPARSER_TYPE_A: 297 case GNUNET_DNSPARSER_TYPE_A:
298 GNUNET_assert (sizeof (struct in_addr) == rd[i].data_size); 298 GNUNET_assert (sizeof (struct in_addr) == rd[i].data_size);
299 rec.name = GNUNET_strdup (packet->queries[0].name); 299 rec.name = GNUNET_strdup (packet->queries[0].name);
300 rec.class = GNUNET_DNSPARSER_CLASS_INTERNET; 300 rec.class = GNUNET_TUN_DNS_CLASS_INTERNET;
301 rec.type = GNUNET_DNSPARSER_TYPE_A; 301 rec.type = GNUNET_DNSPARSER_TYPE_A;
302 rec.data.raw.data = GNUNET_malloc (sizeof (struct in_addr)); 302 rec.data.raw.data = GNUNET_malloc (sizeof (struct in_addr));
303 memcpy (rec.data.raw.data, 303 memcpy (rec.data.raw.data,
@@ -312,7 +312,7 @@ result_processor (void *cls,
312 GNUNET_assert (sizeof (struct in6_addr) == rd[i].data_size); 312 GNUNET_assert (sizeof (struct in6_addr) == rd[i].data_size);
313 rec.name = GNUNET_strdup (packet->queries[0].name); 313 rec.name = GNUNET_strdup (packet->queries[0].name);
314 rec.data.raw.data = GNUNET_malloc (sizeof (struct in6_addr)); 314 rec.data.raw.data = GNUNET_malloc (sizeof (struct in6_addr));
315 rec.class = GNUNET_DNSPARSER_CLASS_INTERNET; 315 rec.class = GNUNET_TUN_DNS_CLASS_INTERNET;
316 rec.type = GNUNET_DNSPARSER_TYPE_AAAA; 316 rec.type = GNUNET_DNSPARSER_TYPE_AAAA;
317 memcpy (rec.data.raw.data, 317 memcpy (rec.data.raw.data,
318 rd[i].data, 318 rd[i].data,
@@ -325,7 +325,7 @@ result_processor (void *cls,
325 case GNUNET_DNSPARSER_TYPE_CNAME: 325 case GNUNET_DNSPARSER_TYPE_CNAME:
326 rec.name = GNUNET_strdup (packet->queries[0].name); 326 rec.name = GNUNET_strdup (packet->queries[0].name);
327 rec.data.hostname = strdup (rd[i].data); 327 rec.data.hostname = strdup (rd[i].data);
328 rec.class = GNUNET_DNSPARSER_CLASS_INTERNET; 328 rec.class = GNUNET_TUN_DNS_CLASS_INTERNET;
329 rec.type = GNUNET_DNSPARSER_TYPE_CNAME; 329 rec.type = GNUNET_DNSPARSER_TYPE_CNAME;
330 memcpy (rec.data.hostname, 330 memcpy (rec.data.hostname,
331 rd[i].data, 331 rd[i].data,
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c
index ec6664454..6097c8611 100644
--- a/src/gns/gnunet-service-gns_interceptor.c
+++ b/src/gns/gnunet-service-gns_interceptor.c
@@ -148,7 +148,7 @@ reply_to_dns (void *cls, uint32_t rd_count,
148 } 148 }
149 GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)); 149 GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
150 answer_records[i].expiration_time.abs_value_us = rd[i].expiration_time; 150 answer_records[i].expiration_time.abs_value_us = rd[i].expiration_time;
151 answer_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET; 151 answer_records[i].class = GNUNET_TUN_DNS_CLASS_INTERNET;
152 } 152 }
153 else 153 else
154 { 154 {
@@ -176,16 +176,16 @@ reply_to_dns (void *cls, uint32_t rd_count,
176 } 176 }
177 GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)); 177 GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
178 additional_records[i].expiration_time.abs_value_us = rd[i].expiration_time; 178 additional_records[i].expiration_time.abs_value_us = rd[i].expiration_time;
179 additional_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET; 179 additional_records[i].class = GNUNET_TUN_DNS_CLASS_INTERNET;
180 } 180 }
181 } 181 }
182 packet->num_answers = num_answers; 182 packet->num_answers = num_answers;
183 packet->num_additional_records = rd_count - num_answers; 183 packet->num_additional_records = rd_count - num_answers;
184 packet->flags.authoritative_answer = 1; 184 packet->flags.authoritative_answer = 1;
185 if (NULL == rd) 185 if (NULL == rd)
186 packet->flags.return_code = GNUNET_DNSPARSER_RETURN_CODE_NAME_ERROR; 186 packet->flags.return_code = GNUNET_TUN_DNS_RETURN_CODE_NAME_ERROR;
187 else 187 else
188 packet->flags.return_code = GNUNET_DNSPARSER_RETURN_CODE_NO_ERROR; 188 packet->flags.return_code = GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR;
189 packet->flags.query_or_response = 1; 189 packet->flags.query_or_response = 1;
190 ret = GNUNET_DNSPARSER_pack (packet, 190 ret = GNUNET_DNSPARSER_pack (packet,
191 1024, /* maximum allowed size for DNS reply */ 191 1024, /* maximum allowed size for DNS reply */
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index a5db51db3..327986415 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -39,9 +39,7 @@
39#include "gnunet_dns_service.h" 39#include "gnunet_dns_service.h"
40#include "gnunet_resolver_service.h" 40#include "gnunet_resolver_service.h"
41#include "gnunet_dnsparser_lib.h" 41#include "gnunet_dnsparser_lib.h"
42#include "gns_protocol.h"
43#include "gnunet_gns_service.h" 42#include "gnunet_gns_service.h"
44#include "gns_common.h"
45#include "gns.h" 43#include "gns.h"
46#include "gnunet-service-gns_resolver.h" 44#include "gnunet-service-gns_resolver.h"
47#include "gnunet_vpn_service.h" 45#include "gnunet_vpn_service.h"
@@ -1168,7 +1166,7 @@ resolve_record_dns (struct ResolverHandle *rh,
1168 struct RecordLookupHandle *rlh = rh->proc_cls; 1166 struct RecordLookupHandle *rlh = rh->proc_cls;
1169 struct GNUNET_DNSPARSER_Query query; 1167 struct GNUNET_DNSPARSER_Query query;
1170 struct GNUNET_DNSPARSER_Packet packet; 1168 struct GNUNET_DNSPARSER_Packet packet;
1171 struct GNUNET_DNSPARSER_Flags flags; 1169 struct GNUNET_TUN_DnsFlags flags;
1172 struct in_addr dnsip; 1170 struct in_addr dnsip;
1173 struct sockaddr_in addr; 1171 struct sockaddr_in addr;
1174 struct sockaddr *sa; 1172 struct sockaddr *sa;
@@ -1242,7 +1240,7 @@ resolve_record_dns (struct ResolverHandle *rh,
1242 } 1240 }
1243 query.name = rh->dns_name; 1241 query.name = rh->dns_name;
1244 query.type = rlh->record_type; 1242 query.type = rlh->record_type;
1245 query.class = GNUNET_DNSPARSER_CLASS_INTERNET; 1243 query.class = GNUNET_TUN_DNS_CLASS_INTERNET;
1246 memset (&flags, 0, sizeof (flags)); 1244 memset (&flags, 0, sizeof (flags));
1247 flags.recursion_desired = 1; 1245 flags.recursion_desired = 1;
1248 flags.checking_disabled = 1; 1246 flags.checking_disabled = 1;
@@ -1293,7 +1291,7 @@ resolve_record_vpn (struct ResolverHandle *rh,
1293{ 1291{
1294 struct RecordLookupHandle *rlh = rh->proc_cls; 1292 struct RecordLookupHandle *rlh = rh->proc_cls;
1295 struct GNUNET_HashCode serv_desc; 1293 struct GNUNET_HashCode serv_desc;
1296 struct vpn_data* vpn; 1294 struct GNUNET_TUN_GnsVpnRecord* vpn;
1297 int af; 1295 int af;
1298 1296
1299 /* We cancel here as to not include the ns lookup in the timeout */ 1297 /* We cancel here as to not include the ns lookup in the timeout */
@@ -1313,7 +1311,7 @@ resolve_record_vpn (struct ResolverHandle *rh,
1313 rh->priv_key); 1311 rh->priv_key);
1314 } 1312 }
1315 1313
1316 vpn = (struct vpn_data*)rd->data; 1314 vpn = (struct GNUNET_TUN_GnsVpnRecord*)rd->data;
1317 GNUNET_CRYPTO_hash ((char*)&vpn[1], 1315 GNUNET_CRYPTO_hash ((char*)&vpn[1],
1318 strlen ((char*)&vpn[1]) + 1, 1316 strlen ((char*)&vpn[1]) + 1,
1319 &serv_desc); 1317 &serv_desc);
@@ -1788,10 +1786,10 @@ finish_lookup (struct ResolverHandle *rh,
1788 char new_mx_data[MAX_MX_LENGTH]; 1786 char new_mx_data[MAX_MX_LENGTH];
1789 char new_soa_data[MAX_SOA_LENGTH]; 1787 char new_soa_data[MAX_SOA_LENGTH];
1790 char new_srv_data[MAX_SRV_LENGTH]; 1788 char new_srv_data[MAX_SRV_LENGTH];
1791 struct srv_data *old_srv; 1789 struct GNUNET_TUN_DnsSrvRecord *old_srv;
1792 struct srv_data *new_srv; 1790 struct GNUNET_TUN_DnsSrvRecord *new_srv;
1793 struct soa_data *old_soa; 1791 struct GNUNET_TUN_DnsSoaRecord *old_soa;
1794 struct soa_data *new_soa; 1792 struct GNUNET_TUN_DnsSoaRecord *new_soa;
1795 struct GNUNET_NAMESTORE_RecordData p_rd[rd_count]; 1793 struct GNUNET_NAMESTORE_RecordData p_rd[rd_count];
1796 char* repl_string; 1794 char* repl_string;
1797 char* pos; 1795 char* pos;
@@ -1853,8 +1851,8 @@ finish_lookup (struct ResolverHandle *rh,
1853 /* 1851 /*
1854 * Prio, weight and port 1852 * Prio, weight and port
1855 */ 1853 */
1856 new_srv = (struct srv_data*)new_srv_data; 1854 new_srv = (struct GNUNET_TUN_DnsSrvRecord*)new_srv_data;
1857 old_srv = (struct srv_data*)rd[i].data; 1855 old_srv = (struct GNUNET_TUN_DnsSrvRecord*)rd[i].data;
1858 new_srv->prio = old_srv->prio; 1856 new_srv->prio = old_srv->prio;
1859 new_srv->weight = old_srv->weight; 1857 new_srv->weight = old_srv->weight;
1860 new_srv->port = old_srv->port; 1858 new_srv->port = old_srv->port;
@@ -1862,14 +1860,14 @@ finish_lookup (struct ResolverHandle *rh,
1862 expand_plus((char*)&new_srv[1], (char*)&old_srv[1], 1860 expand_plus((char*)&new_srv[1], (char*)&old_srv[1],
1863 repl_string); 1861 repl_string);
1864 p_rd[i].data = new_srv_data; 1862 p_rd[i].data = new_srv_data;
1865 p_rd[i].data_size = sizeof (struct srv_data) + strlen ((char*)&new_srv[1]) + 1; 1863 p_rd[i].data_size = sizeof (struct GNUNET_TUN_DnsSrvRecord) + strlen ((char*)&new_srv[1]) + 1;
1866 } 1864 }
1867 else if (GNUNET_DNSPARSER_TYPE_SOA == rd[i].record_type) 1865 else if (GNUNET_DNSPARSER_TYPE_SOA == rd[i].record_type)
1868 { 1866 {
1869 /* expand mname and rname */ 1867 /* expand mname and rname */
1870 old_soa = (struct soa_data*)rd[i].data; 1868 old_soa = (struct GNUNET_TUN_DnsSoaRecord*)rd[i].data;
1871 new_soa = (struct soa_data*)new_soa_data; 1869 new_soa = (struct GNUNET_TUN_DnsSoaRecord*)new_soa_data;
1872 memcpy (new_soa, old_soa, sizeof (struct soa_data)); 1870 memcpy (new_soa, old_soa, sizeof (struct GNUNET_TUN_DnsSoaRecord));
1873 // FIXME: how do we know that 'new_soa[1]' has enough space for the new name? 1871 // FIXME: how do we know that 'new_soa[1]' has enough space for the new name?
1874 expand_plus((char*)&new_soa[1], (char*)&old_soa[1], repl_string); 1872 expand_plus((char*)&new_soa[1], (char*)&old_soa[1], repl_string);
1875 offset = strlen ((char*)&new_soa[1]) + 1; 1873 offset = strlen ((char*)&new_soa[1]) + 1;
@@ -1877,7 +1875,7 @@ finish_lookup (struct ResolverHandle *rh,
1877 expand_plus((char*)&new_soa[1] + offset, 1875 expand_plus((char*)&new_soa[1] + offset,
1878 (char*)&old_soa[1] + strlen ((char*)&old_soa[1]) + 1, 1876 (char*)&old_soa[1] + strlen ((char*)&old_soa[1]) + 1,
1879 repl_string); 1877 repl_string);
1880 p_rd[i].data_size = sizeof (struct soa_data) 1878 p_rd[i].data_size = sizeof (struct GNUNET_TUN_DnsSoaRecord)
1881 + offset 1879 + offset
1882 + strlen ((char*)&new_soa[1] + offset); 1880 + strlen ((char*)&new_soa[1] + offset);
1883 p_rd[i].data = new_soa_data; 1881 p_rd[i].data = new_soa_data;
@@ -2889,13 +2887,13 @@ recursive_dns_resolution (struct GNS_ResolverHandle *rh)
2889 query = GNUNET_new (struct GNUNET_DNSPARSER_Query); 2887 query = GNUNET_new (struct GNUNET_DNSPARSER_Query);
2890 query->name = GNUNET_strdup (ac->label); 2888 query->name = GNUNET_strdup (ac->label);
2891 query->type = rh->record_type; 2889 query->type = rh->record_type;
2892 query->class = GNUNET_DNSPARSER_CLASS_INTERNET; 2890 query->class = GNUNET_TUN_DNS_CLASS_INTERNET;
2893 p = GNUNET_new (struct GNUNET_DNSPARSER_Packet); 2891 p = GNUNET_new (struct GNUNET_DNSPARSER_Packet);
2894 p->queries = query; 2892 p->queries = query;
2895 p->num_queries = 1; 2893 p->num_queries = 1;
2896 p->id = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 2894 p->id = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
2897 UINT16_MAX); 2895 UINT16_MAX);
2898 p->flags.opcode = GNUNET_DNSPARSER_OPCODE_QUERY; 2896 p->flags.opcode = GNUNET_TUN_DNS_OPCODE_QUERY;
2899 p->flags.recursion_desired = 1; 2897 p->flags.recursion_desired = 1;
2900 if (GNUNET_OK != 2898 if (GNUNET_OK !=
2901 GNUNET_DNSPARSER_pack (p, 1024, &dns_request, &dns_request_length)) 2899 GNUNET_DNSPARSER_pack (p, 1024, &dns_request, &dns_request_length))
diff --git a/src/gns/test_gns_simple_srv_lookup.c b/src/gns/test_gns_simple_srv_lookup.c
index 498b7e131..d9de98af8 100644
--- a/src/gns/test_gns_simple_srv_lookup.c
+++ b/src/gns/test_gns_simple_srv_lookup.c
@@ -189,7 +189,7 @@ do_check (void *cls,
189 struct GNUNET_CRYPTO_ShortHashCode bob_hash; 189 struct GNUNET_CRYPTO_ShortHashCode bob_hash;
190 struct GNUNET_CRYPTO_EccSignature *sig; 190 struct GNUNET_CRYPTO_EccSignature *sig;
191 char* alice_keyfile; 191 char* alice_keyfile;
192 struct srv_data *srv_data; 192 struct GNUNET_TUN_DnsSrvRecord *srv_data;
193 struct GNUNET_TIME_Absolute et; 193 struct GNUNET_TIME_Absolute et;
194 194
195 cfg = ccfg; 195 cfg = ccfg;
@@ -222,7 +222,7 @@ do_check (void *cls,
222 struct GNUNET_NAMESTORE_RecordData rd; 222 struct GNUNET_NAMESTORE_RecordData rd;
223 char* ip = TEST_IP; 223 char* ip = TEST_IP;
224 struct in_addr *sipserver = GNUNET_malloc (sizeof (struct in_addr)); 224 struct in_addr *sipserver = GNUNET_malloc (sizeof (struct in_addr));
225 srv_data = GNUNET_malloc (sizeof (struct srv_data) + strlen (TEST_SRV_NAME) + 1); 225 srv_data = GNUNET_malloc (sizeof (struct GNUNET_TUN_DnsSrvRecord) + strlen (TEST_SRV_NAME) + 1);
226 uint16_t srv_weight = 60; 226 uint16_t srv_weight = 60;
227 uint16_t srv_prio = 50; 227 uint16_t srv_prio = 50;
228 uint16_t srv_port = 5060; 228 uint16_t srv_port = 5060;
@@ -263,7 +263,7 @@ do_check (void *cls,
263 NULL); 263 NULL);
264 GNUNET_free (sig); 264 GNUNET_free (sig);
265 265
266 rd.data_size = sizeof (struct srv_data)+strlen(TEST_SRV_NAME)+1; 266 rd.data_size = sizeof (struct GNUNET_TUN_DnsSrvRecord)+strlen(TEST_SRV_NAME)+1;
267 srv_data->port = srv_port; 267 srv_data->port = srv_port;
268 srv_data->prio = srv_prio; 268 srv_data->prio = srv_prio;
269 srv_data->weight = srv_weight; 269 srv_data->weight = srv_weight;
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
19gnunetinclude_HEADERS = \ 19gnunetinclude_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
29GNUNET_NETWORK_STRUCT_BEGIN
30
31/**
32 * Payload of DNS SOA record (header).
33 */
34struct 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 */
69struct 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 */
99struct 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 */
144struct 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
159GNUNET_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 */
91struct 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 */
184struct GNUNET_TUN_TcpHeader 184struct 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 */
245struct GNUNET_TUN_UdpHeader 252struct 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 */
313struct 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 */
257struct GNUNET_TUN_DnsHeader 428struct 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 */
465struct 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 */
500struct 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 */
530struct 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 */
576struct 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 */
594struct 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 */
611struct 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 */
369void 737void
370GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, 738GNUNET_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 */
397void 765void
398GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, 766GNUNET_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 */
440void 808void
@@ -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 */
453void 821void
@@ -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
diff --git a/src/namestore/namestore_api_common.c b/src/namestore/namestore_api_common.c
index 397a649aa..f0f061d0f 100644
--- a/src/namestore/namestore_api_common.c
+++ b/src/namestore/namestore_api_common.c
@@ -25,7 +25,6 @@
25 * @author Matthias Wachs 25 * @author Matthias Wachs
26 * @author Christian Grothoff 26 * @author Christian Grothoff
27 */ 27 */
28
29#include "platform.h" 28#include "platform.h"
30#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
31#include "gnunet_constants.h" 30#include "gnunet_constants.h"
@@ -33,7 +32,7 @@
33#include "gnunet_arm_service.h" 32#include "gnunet_arm_service.h"
34#include "gnunet_namestore_service.h" 33#include "gnunet_namestore_service.h"
35#include "gnunet_dnsparser_lib.h" 34#include "gnunet_dnsparser_lib.h"
36#include "gns_protocol.h" 35#include "gnunet_tun_lib.h"
37#include "namestore.h" 36#include "namestore.h"
38 37
39 38
@@ -508,10 +507,10 @@ GNUNET_NAMESTORE_value_to_string (uint32_t type,
508 size_t data_size) 507 size_t data_size)
509{ 508{
510 uint16_t mx_pref; 509 uint16_t mx_pref;
511 const struct soa_data *soa; 510 const struct GNUNET_TUN_DnsSoaRecord *soa;
512 const struct vpn_data *vpn; 511 const struct GNUNET_TUN_GnsVpnRecord *vpn;
513 const struct srv_data *srv; 512 const struct GNUNET_TUN_DnsSrvRecord *srv;
514 const struct tlsa_data *tlsa; 513 const struct GNUNET_TUN_DnsTlsaRecord *tlsa;
515 struct GNUNET_CRYPTO_HashAsciiEncoded s_peer; 514 struct GNUNET_CRYPTO_HashAsciiEncoded s_peer;
516 const char *cdata; 515 const char *cdata;
517 char* vpn_str; 516 char* vpn_str;
@@ -537,16 +536,16 @@ GNUNET_NAMESTORE_value_to_string (uint32_t type,
537 case GNUNET_DNSPARSER_TYPE_CNAME: 536 case GNUNET_DNSPARSER_TYPE_CNAME:
538 return GNUNET_strndup (data, data_size); 537 return GNUNET_strndup (data, data_size);
539 case GNUNET_DNSPARSER_TYPE_SOA: 538 case GNUNET_DNSPARSER_TYPE_SOA:
540 if (data_size <= sizeof (struct soa_data)) 539 if (data_size <= sizeof (struct GNUNET_TUN_DnsSoaRecord))
541 return NULL; 540 return NULL;
542 soa = data; 541 soa = data;
543 soa_rname = (const char*) &soa[1]; 542 soa_rname = (const char*) &soa[1];
544 soa_mname = memchr (soa_rname, 0, data_size - sizeof (struct soa_data) - 1); 543 soa_mname = memchr (soa_rname, 0, data_size - sizeof (struct GNUNET_TUN_DnsSoaRecord) - 1);
545 if (NULL == soa_mname) 544 if (NULL == soa_mname)
546 return NULL; 545 return NULL;
547 soa_mname++; 546 soa_mname++;
548 if (NULL == memchr (soa_mname, 0, 547 if (NULL == memchr (soa_mname, 0,
549 data_size - (sizeof (struct soa_data) + strlen (soa_rname) + 1))) 548 data_size - (sizeof (struct GNUNET_TUN_DnsSoaRecord) + strlen (soa_rname) + 1)))
550 return NULL; 549 return NULL;
551 GNUNET_asprintf (&result, 550 GNUNET_asprintf (&result,
552 "rname=%s mname=%s %lu,%lu,%lu,%lu,%lu", 551 "rname=%s mname=%s %lu,%lu,%lu,%lu,%lu",
@@ -587,7 +586,7 @@ GNUNET_NAMESTORE_value_to_string (uint32_t type,
587 return GNUNET_strndup (data, data_size); 586 return GNUNET_strndup (data, data_size);
588 case GNUNET_NAMESTORE_TYPE_VPN: 587 case GNUNET_NAMESTORE_TYPE_VPN:
589 cdata = data; 588 cdata = data;
590 if ( (data_size <= sizeof (struct vpn_data)) || 589 if ( (data_size <= sizeof (struct GNUNET_TUN_GnsVpnRecord)) ||
591 ('\0' != cdata[data_size - 1]) ) 590 ('\0' != cdata[data_size - 1]) )
592 return NULL; /* malformed */ 591 return NULL; /* malformed */
593 vpn = data; 592 vpn = data;
@@ -603,7 +602,7 @@ GNUNET_NAMESTORE_value_to_string (uint32_t type,
603 return vpn_str; 602 return vpn_str;
604 case GNUNET_DNSPARSER_TYPE_SRV: 603 case GNUNET_DNSPARSER_TYPE_SRV:
605 cdata = data; 604 cdata = data;
606 if ( (data_size <= sizeof (struct srv_data)) || 605 if ( (data_size <= sizeof (struct GNUNET_TUN_DnsSrvRecord)) ||
607 ('\0' != cdata[data_size - 1]) ) 606 ('\0' != cdata[data_size - 1]) )
608 return NULL; /* malformed */ 607 return NULL; /* malformed */
609 srv = data; 608 srv = data;
@@ -621,7 +620,7 @@ GNUNET_NAMESTORE_value_to_string (uint32_t type,
621 return srv_str; 620 return srv_str;
622 case GNUNET_DNSPARSER_TYPE_TLSA: 621 case GNUNET_DNSPARSER_TYPE_TLSA:
623 cdata = data; 622 cdata = data;
624 if ( (data_size <= sizeof (struct tlsa_data)) || 623 if ( (data_size <= sizeof (struct GNUNET_TUN_DnsTlsaRecord)) ||
625 ('\0' != cdata[data_size - 1]) ) 624 ('\0' != cdata[data_size - 1]) )
626 return NULL; /* malformed */ 625 return NULL; /* malformed */
627 tlsa = data; 626 tlsa = data;
@@ -663,9 +662,9 @@ GNUNET_NAMESTORE_string_to_value (uint32_t type,
663 struct in_addr value_a; 662 struct in_addr value_a;
664 struct in6_addr value_aaaa; 663 struct in6_addr value_aaaa;
665 struct GNUNET_CRYPTO_EccPublicKey pkey; 664 struct GNUNET_CRYPTO_EccPublicKey pkey;
666 struct soa_data *soa; 665 struct GNUNET_TUN_DnsSoaRecord *soa;
667 struct vpn_data *vpn; 666 struct GNUNET_TUN_GnsVpnRecord *vpn;
668 struct tlsa_data *tlsa; 667 struct GNUNET_TUN_DnsTlsaRecord *tlsa;
669 char result[253 + 1]; 668 char result[253 + 1];
670 char soa_rname[253 + 1]; 669 char soa_rname[253 + 1];
671 char soa_mname[253 + 1]; 670 char soa_mname[253 + 1];
@@ -720,9 +719,9 @@ GNUNET_NAMESTORE_string_to_value (uint32_t type,
720 s); 719 s);
721 return GNUNET_SYSERR; 720 return GNUNET_SYSERR;
722 } 721 }
723 *data_size = sizeof (struct soa_data)+strlen(soa_rname)+strlen(soa_mname)+2; 722 *data_size = sizeof (struct GNUNET_TUN_DnsSoaRecord)+strlen(soa_rname)+strlen(soa_mname)+2;
724 *data = GNUNET_malloc (*data_size); 723 *data = GNUNET_malloc (*data_size);
725 soa = (struct soa_data*)*data; 724 soa = (struct GNUNET_TUN_DnsSoaRecord*)*data;
726 soa->serial = htonl(soa_serial); 725 soa->serial = htonl(soa_serial);
727 soa->refresh = htonl(soa_refresh); 726 soa->refresh = htonl(soa_refresh);
728 soa->retry = htonl(soa_retry); 727 soa->retry = htonl(soa_retry);
@@ -795,7 +794,7 @@ GNUNET_NAMESTORE_string_to_value (uint32_t type,
795 s); 794 s);
796 return GNUNET_SYSERR; 795 return GNUNET_SYSERR;
797 } 796 }
798 *data_size = sizeof (struct vpn_data) + strlen (s_serv) + 1; 797 *data_size = sizeof (struct GNUNET_TUN_GnsVpnRecord) + strlen (s_serv) + 1;
799 *data = vpn = GNUNET_malloc (*data_size); 798 *data = vpn = GNUNET_malloc (*data_size);
800 if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string ((char*)&s_peer, 799 if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string ((char*)&s_peer,
801 &vpn->peer)) 800 &vpn->peer))
@@ -808,7 +807,7 @@ GNUNET_NAMESTORE_string_to_value (uint32_t type,
808 strcpy ((char*)&vpn[1], s_serv); 807 strcpy ((char*)&vpn[1], s_serv);
809 return GNUNET_OK; 808 return GNUNET_OK;
810 case GNUNET_DNSPARSER_TYPE_TLSA: 809 case GNUNET_DNSPARSER_TYPE_TLSA:
811 *data_size = sizeof (struct tlsa_data) + strlen (s) - 6; 810 *data_size = sizeof (struct GNUNET_TUN_DnsTlsaRecord) + strlen (s) - 6;
812 *data = tlsa = GNUNET_malloc (*data_size); 811 *data = tlsa = GNUNET_malloc (*data_size);
813 if (4 != SSCANF (s, "%c %c %c %s", 812 if (4 != SSCANF (s, "%c %c %c %s",
814 &tlsa->usage, 813 &tlsa->usage,