diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-12 19:09:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-12 19:09:52 +0000 |
commit | 5e05019536c0d38bf20f965613636f21ae7c2be6 (patch) | |
tree | eda1dee12e49c010171462d618162d28b21c9c6a /src/namestore/namestore.h | |
parent | 566dfe32be22ed1f071b974be3c4dd8bc5721151 (diff) | |
download | gnunet-5e05019536c0d38bf20f965613636f21ae7c2be6.tar.gz gnunet-5e05019536c0d38bf20f965613636f21ae7c2be6.zip |
-towards namestore support for the new privacy-preserving GNS queries
Diffstat (limited to 'src/namestore/namestore.h')
-rw-r--r-- | src/namestore/namestore.h | 261 |
1 files changed, 97 insertions, 164 deletions
diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h index 58ecbf65d..ca712e136 100644 --- a/src/namestore/namestore.h +++ b/src/namestore/namestore.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2011-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 |
@@ -22,6 +22,7 @@ | |||
22 | * @file namestore/namestore.h | 22 | * @file namestore/namestore.h |
23 | * @brief common internal definitions for namestore service | 23 | * @brief common internal definitions for namestore service |
24 | * @author Matthias Wachs | 24 | * @author Matthias Wachs |
25 | * @author Christian Grothoff | ||
25 | */ | 26 | */ |
26 | #ifndef NAMESTORE_H | 27 | #ifndef NAMESTORE_H |
27 | #define NAMESTORE_H | 28 | #define NAMESTORE_H |
@@ -33,51 +34,6 @@ | |||
33 | 34 | ||
34 | GNUNET_NETWORK_STRUCT_BEGIN | 35 | GNUNET_NETWORK_STRUCT_BEGIN |
35 | 36 | ||
36 | |||
37 | /** | ||
38 | * A GNS record serialized for network transmission. | ||
39 | * | ||
40 | * Layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data] | ||
41 | */ | ||
42 | struct GNUNET_NAMESTORE_NetworkRecord | ||
43 | { | ||
44 | /** | ||
45 | * Expiration time for the DNS record. | ||
46 | */ | ||
47 | struct GNUNET_TIME_AbsoluteNBO expiration; | ||
48 | |||
49 | /** | ||
50 | * Number of bytes in 'data'. | ||
51 | */ | ||
52 | uint32_t data_size; | ||
53 | |||
54 | /** | ||
55 | * Type of the GNS/DNS record. | ||
56 | */ | ||
57 | uint32_t record_type; | ||
58 | |||
59 | /** | ||
60 | * Flags for the record. | ||
61 | */ | ||
62 | uint32_t flags; | ||
63 | }; | ||
64 | |||
65 | |||
66 | |||
67 | /** | ||
68 | * Connect to namestore service. FIXME: UNNECESSARY. | ||
69 | */ | ||
70 | struct StartMessage | ||
71 | { | ||
72 | |||
73 | /** | ||
74 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_START | ||
75 | */ | ||
76 | struct GNUNET_MessageHeader header; | ||
77 | |||
78 | }; | ||
79 | |||
80 | |||
81 | /** | 37 | /** |
82 | * Generic namestore message with op id | 38 | * Generic namestore message with op id |
83 | */ | 39 | */ |
@@ -97,38 +53,30 @@ struct GNUNET_NAMESTORE_Header | |||
97 | 53 | ||
98 | 54 | ||
99 | /** | 55 | /** |
100 | * Lookup a name in the namestore | 56 | * Lookup a block in the namestore |
101 | */ | 57 | */ |
102 | struct LookupNameMessage | 58 | struct LookupBlockMessage |
103 | { | 59 | { |
104 | struct GNUNET_NAMESTORE_Header gns_header; | ||
105 | |||
106 | /** | ||
107 | * The zone | ||
108 | */ | ||
109 | struct GNUNET_CRYPTO_ShortHashCode zone; | ||
110 | |||
111 | /** | 60 | /** |
112 | * Requested record type | 61 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK |
113 | */ | 62 | */ |
114 | uint32_t record_type; | 63 | struct GNUNET_NAMESTORE_Header gns_header; |
115 | 64 | ||
116 | /** | 65 | /** |
117 | * Length of the name | 66 | * The query. |
118 | */ | 67 | */ |
119 | uint32_t name_len; | 68 | struct GNUNET_HashCode query; |
120 | 69 | ||
121 | /* 0-terminated name here */ | ||
122 | }; | 70 | }; |
123 | 71 | ||
124 | 72 | ||
125 | /** | 73 | /** |
126 | * Lookup response | 74 | * Lookup response |
127 | */ | 75 | */ |
128 | struct LookupNameResponseMessage | 76 | struct LookupBlockResponseMessage |
129 | { | 77 | { |
130 | /** | 78 | /** |
131 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE | 79 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK_RESPONSE |
132 | */ | 80 | */ |
133 | struct GNUNET_NAMESTORE_Header gns_header; | 81 | struct GNUNET_NAMESTORE_Header gns_header; |
134 | 82 | ||
@@ -138,48 +86,26 @@ struct LookupNameResponseMessage | |||
138 | struct GNUNET_TIME_AbsoluteNBO expire; | 86 | struct GNUNET_TIME_AbsoluteNBO expire; |
139 | 87 | ||
140 | /** | 88 | /** |
141 | * Name length | 89 | * Signature. |
142 | */ | ||
143 | uint16_t name_len; | ||
144 | |||
145 | /** | ||
146 | * Bytes of serialized record data | ||
147 | */ | ||
148 | uint16_t rd_len; | ||
149 | |||
150 | /** | ||
151 | * Number of records contained | ||
152 | */ | ||
153 | uint16_t rd_count; | ||
154 | |||
155 | /** | ||
156 | * Is the signature valid | ||
157 | * GNUNET_YES or GNUNET_NO | ||
158 | */ | ||
159 | int16_t contains_sig; | ||
160 | |||
161 | /** | ||
162 | * All zeros if 'contains_sig' is GNUNET_NO. | ||
163 | */ | 90 | */ |
164 | struct GNUNET_CRYPTO_EccSignature signature; | 91 | struct GNUNET_CRYPTO_EccSignature signature; |
165 | 92 | ||
166 | /** | 93 | /** |
167 | * The public key for the name | 94 | * Derived public key. |
168 | */ | 95 | */ |
169 | struct GNUNET_CRYPTO_EccPublicKey public_key; | 96 | struct GNUNET_CRYPTO_EccPublicKey derived_key; |
170 | 97 | ||
171 | /* 0-terminated name and serialized record data */ | 98 | /* follwed by encrypted block data */ |
172 | /* rd_len bytes serialized record data */ | ||
173 | }; | 99 | }; |
174 | 100 | ||
175 | 101 | ||
176 | /** | 102 | /** |
177 | * Put a record to the namestore | 103 | * Cache a record in the namestore. |
178 | */ | 104 | */ |
179 | struct RecordPutMessage | 105 | struct BlockCacheMessage |
180 | { | 106 | { |
181 | /** | 107 | /** |
182 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_PUT | 108 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE |
183 | */ | 109 | */ |
184 | struct GNUNET_NAMESTORE_Header gns_header; | 110 | struct GNUNET_NAMESTORE_Header gns_header; |
185 | 111 | ||
@@ -189,70 +115,49 @@ struct RecordPutMessage | |||
189 | struct GNUNET_TIME_AbsoluteNBO expire; | 115 | struct GNUNET_TIME_AbsoluteNBO expire; |
190 | 116 | ||
191 | /** | 117 | /** |
192 | * Name length | 118 | * Signature. |
193 | */ | ||
194 | uint16_t name_len; | ||
195 | |||
196 | /** | ||
197 | * Length of serialized record data | ||
198 | */ | ||
199 | uint16_t rd_len; | ||
200 | |||
201 | /** | ||
202 | * Number of records contained | ||
203 | */ | ||
204 | uint16_t rd_count; | ||
205 | |||
206 | /** | ||
207 | * always zero (for alignment) | ||
208 | */ | ||
209 | uint16_t reserved; | ||
210 | |||
211 | /** | ||
212 | * The signature | ||
213 | */ | 119 | */ |
214 | struct GNUNET_CRYPTO_EccSignature signature; | 120 | struct GNUNET_CRYPTO_EccSignature signature; |
215 | 121 | ||
216 | /** | 122 | /** |
217 | * The public key | 123 | * Derived public key. |
218 | */ | 124 | */ |
219 | struct GNUNET_CRYPTO_EccPublicKey public_key; | 125 | struct GNUNET_CRYPTO_EccPublicKey derived_key; |
220 | |||
221 | /* name (0-terminated) followed by "rd_count" serialized records */ | ||
222 | 126 | ||
127 | /* follwed by encrypted block data */ | ||
223 | }; | 128 | }; |
224 | 129 | ||
225 | 130 | ||
226 | /** | 131 | /** |
227 | * Put a record to the namestore response | 132 | * Response to a request to cache a block. |
228 | */ | 133 | */ |
229 | struct RecordPutResponseMessage | 134 | struct BlockCacheResponseMessage |
230 | { | 135 | { |
231 | /** | 136 | /** |
232 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE | 137 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE_RESPONSE |
233 | */ | 138 | */ |
234 | struct GNUNET_NAMESTORE_Header gns_header; | 139 | struct GNUNET_NAMESTORE_Header gns_header; |
235 | 140 | ||
236 | /** | 141 | /** |
237 | * result: | 142 | * name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error |
238 | * GNUNET_SYSERR on failure | ||
239 | * GNUNET_OK on success | ||
240 | */ | 143 | */ |
241 | int32_t op_result; | 144 | int32_t op_result; |
242 | }; | 145 | }; |
243 | 146 | ||
244 | 147 | ||
245 | /** | 148 | /** |
246 | * Create a record and put it to the namestore | 149 | * Store a record to the namestore (as authority). |
247 | * Memory layout: | ||
248 | */ | 150 | */ |
249 | struct RecordCreateMessage | 151 | struct RecordStoreMessage |
250 | { | 152 | { |
251 | /** | 153 | /** |
252 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE | 154 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_RECORD_STORE |
253 | */ | 155 | */ |
254 | struct GNUNET_NAMESTORE_Header gns_header; | 156 | struct GNUNET_NAMESTORE_Header gns_header; |
255 | 157 | ||
158 | /** | ||
159 | * Expiration time | ||
160 | */ | ||
256 | struct GNUNET_TIME_AbsoluteNBO expire; | 161 | struct GNUNET_TIME_AbsoluteNBO expire; |
257 | 162 | ||
258 | /** | 163 | /** |
@@ -266,41 +171,47 @@ struct RecordCreateMessage | |||
266 | uint16_t rd_len; | 171 | uint16_t rd_len; |
267 | 172 | ||
268 | /** | 173 | /** |
269 | * Record count | 174 | * Number of records contained |
270 | */ | 175 | */ |
271 | uint16_t rd_count; | 176 | uint16_t rd_count; |
272 | 177 | ||
273 | /** | 178 | /** |
274 | * always zero | 179 | * always zero (for alignment) |
275 | */ | 180 | */ |
276 | uint16_t reserved; | 181 | uint16_t reserved; |
277 | 182 | ||
183 | /** | ||
184 | * The private key of the authority. | ||
185 | */ | ||
278 | struct GNUNET_CRYPTO_EccPrivateKey private_key; | 186 | struct GNUNET_CRYPTO_EccPrivateKey private_key; |
279 | 187 | ||
280 | /* followed by: | 188 | /* followed by: |
281 | * name with length name_len | 189 | * name with length name_len |
282 | * serialized record data with length rd_len | 190 | * serialized record data with rd_count records |
283 | */ | 191 | */ |
284 | }; | 192 | }; |
285 | 193 | ||
286 | 194 | ||
287 | /** | 195 | /** |
288 | * Create a record to the namestore response | 196 | * Response to a record storage request. |
289 | */ | 197 | */ |
290 | struct RecordCreateResponseMessage | 198 | struct RecordStoreResponseMessage |
291 | { | 199 | { |
292 | /** | 200 | /** |
293 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_CREATE_RESPONSE | 201 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE |
294 | */ | 202 | */ |
295 | struct GNUNET_NAMESTORE_Header gns_header; | 203 | struct GNUNET_NAMESTORE_Header gns_header; |
296 | 204 | ||
297 | /** | 205 | /** |
298 | * name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error | 206 | * result: |
207 | * GNUNET_SYSERR on failure | ||
208 | * GNUNET_OK on success | ||
299 | */ | 209 | */ |
300 | int32_t op_result; | 210 | int32_t op_result; |
301 | }; | 211 | }; |
302 | 212 | ||
303 | 213 | ||
214 | |||
304 | /** | 215 | /** |
305 | * Lookup a name for a zone hash | 216 | * Lookup a name for a zone hash |
306 | */ | 217 | */ |
@@ -312,14 +223,14 @@ struct ZoneToNameMessage | |||
312 | struct GNUNET_NAMESTORE_Header gns_header; | 223 | struct GNUNET_NAMESTORE_Header gns_header; |
313 | 224 | ||
314 | /** | 225 | /** |
315 | * The hash of public key of the zone to look up in | 226 | * The private key of the zone to look up in |
316 | */ | 227 | */ |
317 | struct GNUNET_CRYPTO_ShortHashCode zone; | 228 | struct GNUNET_CRYPTO_EccPrivateKey zone; |
318 | 229 | ||
319 | /** | 230 | /** |
320 | * The hash of the public key of the target zone | 231 | * The public key of the target zone |
321 | */ | 232 | */ |
322 | struct GNUNET_CRYPTO_ShortHashCode value_zone; | 233 | struct GNUNET_CRYPTO_EccPublicKey value_zone; |
323 | }; | 234 | }; |
324 | 235 | ||
325 | 236 | ||
@@ -334,11 +245,6 @@ struct ZoneToNameResponseMessage | |||
334 | struct GNUNET_NAMESTORE_Header gns_header; | 245 | struct GNUNET_NAMESTORE_Header gns_header; |
335 | 246 | ||
336 | /** | 247 | /** |
337 | * Record block expiration | ||
338 | */ | ||
339 | struct GNUNET_TIME_AbsoluteNBO expire; | ||
340 | |||
341 | /** | ||
342 | * Length of the name | 248 | * Length of the name |
343 | */ | 249 | */ |
344 | uint16_t name_len; | 250 | uint16_t name_len; |
@@ -360,66 +266,93 @@ struct ZoneToNameResponseMessage | |||
360 | int16_t res; | 266 | int16_t res; |
361 | 267 | ||
362 | /** | 268 | /** |
363 | * Signature | 269 | * The private key of the zone that contained the name. |
364 | */ | 270 | */ |
365 | struct GNUNET_CRYPTO_EccSignature signature; | 271 | struct GNUNET_CRYPTO_EccPrivateKey zone; |
366 | 272 | ||
367 | /** | 273 | /* followed by: |
368 | * Publik key | 274 | * name with length name_len |
275 | * serialized record data with rd_count records | ||
369 | */ | 276 | */ |
370 | struct GNUNET_CRYPTO_EccPublicKey zone_key; | ||
371 | 277 | ||
372 | }; | 278 | }; |
373 | 279 | ||
374 | 280 | ||
375 | /** | 281 | /** |
376 | * Start monitoring a zone. | 282 | * Record is returned from the namestore (as authority). |
377 | */ | 283 | */ |
378 | struct ZoneMonitorStartMessage | 284 | struct RecordResultMessage |
379 | { | 285 | { |
380 | /** | 286 | /** |
381 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START | 287 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT |
382 | */ | 288 | */ |
383 | struct GNUNET_NAMESTORE_Header gns_header; | 289 | struct GNUNET_NAMESTORE_Header gns_header; |
384 | 290 | ||
385 | /** | 291 | /** |
386 | * Zone hash | 292 | * Name length |
293 | */ | ||
294 | uint16_t name_len; | ||
295 | |||
296 | /** | ||
297 | * Length of serialized record data | ||
298 | */ | ||
299 | uint16_t rd_len; | ||
300 | |||
301 | /** | ||
302 | * Number of records contained | ||
303 | */ | ||
304 | uint16_t rd_count; | ||
305 | |||
306 | /** | ||
307 | * always zero (for alignment) | ||
387 | */ | 308 | */ |
388 | struct GNUNET_CRYPTO_ShortHashCode zone; | 309 | uint16_t reserved; |
389 | 310 | ||
390 | /** | 311 | /** |
391 | * All zones. GNUNET_YES to monitor all zones, | 312 | * The private key of the authority. |
392 | * GNUNET_NO to only monitor 'zone'. In NBO. | ||
393 | */ | 313 | */ |
394 | uint32_t all_zones GNUNET_PACKED; | 314 | struct GNUNET_CRYPTO_EccPrivateKey private_key; |
395 | 315 | ||
316 | /* followed by: | ||
317 | * name with length name_len | ||
318 | * serialized record data with rd_count records | ||
319 | */ | ||
396 | }; | 320 | }; |
397 | 321 | ||
398 | 322 | ||
399 | /** | 323 | /** |
400 | * Start a zone iteration for the given zone | 324 | * Start monitoring a zone. |
401 | */ | 325 | */ |
402 | struct ZoneIterationStartMessage | 326 | struct ZoneMonitorStartMessage |
403 | { | 327 | { |
404 | /** | 328 | /** |
405 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START | 329 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START |
406 | */ | 330 | */ |
407 | struct GNUNET_NAMESTORE_Header gns_header; | 331 | struct GNUNET_NAMESTORE_Header gns_header; |
408 | 332 | ||
409 | /** | 333 | /** |
410 | * Zone hash | 334 | * Zone key. |
411 | */ | 335 | */ |
412 | struct GNUNET_CRYPTO_ShortHashCode zone; | 336 | struct GNUNET_CRYPTO_EccPrivateKey zone; |
337 | |||
338 | }; | ||
339 | |||
413 | 340 | ||
341 | /** | ||
342 | * Start a zone iteration for the given zone | ||
343 | */ | ||
344 | struct ZoneIterationStartMessage | ||
345 | { | ||
414 | /** | 346 | /** |
415 | * Which flags must be included | 347 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START |
416 | */ | 348 | */ |
417 | uint16_t must_have_flags; | 349 | struct GNUNET_NAMESTORE_Header gns_header; |
418 | 350 | ||
419 | /** | 351 | /** |
420 | * Which flags must not be included | 352 | * Zone key. |
421 | */ | 353 | */ |
422 | uint16_t must_not_have_flags; | 354 | struct GNUNET_CRYPTO_EccPrivateKey zone; |
355 | |||
423 | }; | 356 | }; |
424 | 357 | ||
425 | 358 | ||