aboutsummaryrefslogtreecommitdiff
path: root/src/dns
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-06-22 12:54:34 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-06-22 12:54:34 +0000
commit66d90f54243ad0ca5953a3aba9ab8aaca159d704 (patch)
treebba06a417916ae611626d21a0e84d5c60e42dea8 /src/dns
parent1acf88bc634b8317d53c8675702e586c7d80724b (diff)
downloadgnunet-66d90f54243ad0ca5953a3aba9ab8aaca159d704.tar.gz
gnunet-66d90f54243ad0ca5953a3aba9ab8aaca159d704.zip
-make record data parsing easier for namestore,gns with dnsparser structs
Diffstat (limited to 'src/dns')
-rw-r--r--src/dns/dnsparser.c150
-rw-r--r--src/dns/dnsparser.h193
2 files changed, 194 insertions, 149 deletions
diff --git a/src/dns/dnsparser.c b/src/dns/dnsparser.c
index 8b8cd22fd..c2afbdf3a 100644
--- a/src/dns/dnsparser.c
+++ b/src/dns/dnsparser.c
@@ -27,157 +27,9 @@
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29#include "gnunet_dnsparser_lib.h" 29#include "gnunet_dnsparser_lib.h"
30#include "dnsparser.h"
30 31
31 32
32GNUNET_NETWORK_STRUCT_BEGIN
33
34/* FIXME: replace this one with the one from tcpip_tun.h!? */
35/**
36 * Head of a any DNS message.
37 */
38struct GNUNET_TUN_DnsHeader
39{
40 /**
41 * Request/response ID. (NBO)
42 */
43 uint16_t id GNUNET_PACKED;
44
45 /**
46 * Flags for the operation.
47 */
48 struct GNUNET_DNSPARSER_Flags flags;
49
50 /**
51 * number of questions (NBO)
52 */
53 uint16_t query_count GNUNET_PACKED;
54
55 /**
56 * number of answers (NBO)
57 */
58 uint16_t answer_rcount GNUNET_PACKED;
59
60 /**
61 * number of authority-records (NBO)
62 */
63 uint16_t authority_rcount GNUNET_PACKED;
64
65 /**
66 * number of additional records (NBO)
67 */
68 uint16_t additional_rcount GNUNET_PACKED;
69};
70
71
72/**
73 * DNS query prefix.
74 */
75struct query_line
76{
77 /**
78 * Desired type (GNUNET_DNSPARSER_TYPE_XXX). (NBO)
79 */
80 uint16_t type GNUNET_PACKED;
81
82 /**
83 * Desired class (usually GNUNET_DNSPARSER_CLASS_INTERNET). (NBO)
84 */
85 uint16_t class GNUNET_PACKED;
86};
87
88
89/**
90 * General DNS record prefix.
91 */
92struct record_line
93{
94 /**
95 * Record type (GNUNET_DNSPARSER_TYPE_XXX). (NBO)
96 */
97 uint16_t type GNUNET_PACKED;
98
99 /**
100 * Record class (usually GNUNET_DNSPARSER_CLASS_INTERNET). (NBO)
101 */
102 uint16_t class GNUNET_PACKED;
103
104 /**
105 * Expiration for the record (in seconds). (NBO)
106 */
107 uint32_t ttl GNUNET_PACKED;
108
109 /**
110 * Number of bytes of data that follow. (NBO)
111 */
112 uint16_t data_len GNUNET_PACKED;
113};
114
115
116/**
117 * Payload of DNS SOA record (header).
118 */
119struct soa_data
120{
121 /**
122 * The version number of the original copy of the zone. (NBO)
123 */
124 uint32_t serial GNUNET_PACKED;
125
126 /**
127 * Time interval before the zone should be refreshed. (NBO)
128 */
129 uint32_t refresh GNUNET_PACKED;
130
131 /**
132 * Time interval that should elapse before a failed refresh should
133 * be retried. (NBO)
134 */
135 uint32_t retry GNUNET_PACKED;
136
137 /**
138 * Time value that specifies the upper limit on the time interval
139 * that can elapse before the zone is no longer authoritative. (NBO)
140 */
141 uint32_t expire GNUNET_PACKED;
142
143 /**
144 * The bit minimum TTL field that should be exported with any RR
145 * from this zone. (NBO)
146 */
147 uint32_t minimum GNUNET_PACKED;
148};
149
150
151/**
152 * Payload of DNS SRV record (header).
153 */
154struct srv_data
155{
156
157 /**
158 * Preference for this entry (lower value is higher preference). Clients
159 * will contact hosts from the lowest-priority group first and fall back
160 * to higher priorities if the low-priority entries are unavailable. (NBO)
161 */
162 uint16_t prio GNUNET_PACKED;
163
164 /**
165 * Relative weight for records with the same priority. Clients will use
166 * the hosts of the same (lowest) priority with a probability proportional
167 * to the weight given. (NBO)
168 */
169 uint16_t weight GNUNET_PACKED;
170
171 /**
172 * TCP or UDP port of the service. (NBO)
173 */
174 uint16_t port GNUNET_PACKED;
175
176 /* followed by 'target' name */
177};
178
179GNUNET_NETWORK_STRUCT_END
180
181 33
182/** 34/**
183 * Parse name inside of a DNS query or record. 35 * Parse name inside of a DNS query or record.
diff --git a/src/dns/dnsparser.h b/src/dns/dnsparser.h
new file mode 100644
index 000000000..e3ab622c7
--- /dev/null
+++ b/src/dns/dnsparser.h
@@ -0,0 +1,193 @@
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 * Payload of GNS VPN record
177 */
178struct vpn_data
179{
180 /**
181 * The protocol to use
182 */
183 uint16_t proto;
184
185 /**
186 * The peer to contact
187 */
188 struct GNUNET_HashCode peer;
189
190 /* followed by the servicename */
191};
192
193GNUNET_NETWORK_STRUCT_END