api communication done
[oweals/gnunet.git] / src / namestore / namestore.h
1 /*
2      This file is part of GNUnet.
3      (C) 2011-2013 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 3, 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 namestore/namestore.h
23  * @brief common internal definitions for namestore service
24  * @author Matthias Wachs
25  * @author Christian Grothoff
26  */
27 #ifndef NAMESTORE_H
28 #define NAMESTORE_H
29
30 /**
31  * Maximum length of any name, including 0-termination.
32  */
33 #define MAX_NAME_LEN 256
34
35 GNUNET_NETWORK_STRUCT_BEGIN
36
37 /**
38  * Generic namestore message with op id
39  */
40 struct GNUNET_NAMESTORE_Header
41 {
42   /**
43    * header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
44    * header.size will be message size
45    */
46   struct GNUNET_MessageHeader header;
47
48   /**
49    * Request ID in NBO
50    */
51   uint32_t r_id GNUNET_PACKED;
52 };
53
54
55 /**
56  * Lookup a block in the namestore
57  */
58 struct LookupBlockMessage
59 {
60   /**
61    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK
62    */
63   struct GNUNET_NAMESTORE_Header gns_header;
64
65   /**
66    * The query.
67    */
68   struct GNUNET_HashCode query GNUNET_PACKED;
69
70 };
71
72
73 /**
74  * Lookup response
75  */
76 struct LookupBlockResponseMessage
77 {
78   /**
79    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_BLOCK_RESPONSE
80    */
81   struct GNUNET_NAMESTORE_Header gns_header;
82
83   /**
84    * Expiration time
85    */
86   struct GNUNET_TIME_AbsoluteNBO expire;
87
88   /**
89    * Signature.
90    */
91   struct GNUNET_CRYPTO_EcdsaSignature signature;
92
93   /**
94    * Derived public key.
95    */
96   struct GNUNET_CRYPTO_EcdsaPublicKey derived_key;
97
98   /* followed by encrypted block data */
99 };
100
101
102 /**
103  * Cache a record in the namestore.
104  */
105 struct BlockCacheMessage
106 {
107   /**
108    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE
109    */
110   struct GNUNET_NAMESTORE_Header gns_header;
111
112   /**
113    * Expiration time
114    */
115   struct GNUNET_TIME_AbsoluteNBO expire;
116
117   /**
118    * Signature.
119    */
120   struct GNUNET_CRYPTO_EcdsaSignature signature;
121
122   /**
123    * Derived public key.
124    */
125   struct GNUNET_CRYPTO_EcdsaPublicKey derived_key;
126
127   /* follwed by encrypted block data */
128 };
129
130
131 /**
132  * Response to a request to cache a block.
133  */
134 struct BlockCacheResponseMessage
135 {
136   /**
137    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE_RESPONSE
138    */
139   struct GNUNET_NAMESTORE_Header gns_header;
140
141   /**
142    * #GNUNET_OK on success, #GNUNET_SYSERR error
143    */
144   int32_t op_result GNUNET_PACKED;
145 };
146
147
148 /**
149  * Store a record to the namestore (as authority).
150  */
151 struct RecordStoreMessage
152 {
153   /**
154    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE
155    */
156   struct GNUNET_NAMESTORE_Header gns_header;
157
158   /**
159    * Expiration time
160    */
161   struct GNUNET_TIME_AbsoluteNBO expire;
162
163   /**
164    * Name length
165    */
166   uint16_t name_len GNUNET_PACKED;
167
168   /**
169    * Length of serialized record data
170    */
171   uint16_t rd_len GNUNET_PACKED;
172
173   /**
174    * Number of records contained
175    */
176   uint16_t rd_count GNUNET_PACKED;
177
178   /**
179    * always zero (for alignment)
180    */
181   uint16_t reserved GNUNET_PACKED;
182
183   /**
184    * The private key of the authority.
185    */
186   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
187
188   /* followed by:
189    * name with length name_len
190    * serialized record data with rd_count records
191    */
192 };
193
194
195 /**
196  * Response to a record storage request.
197  */
198 struct RecordStoreResponseMessage
199 {
200   /**
201    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE
202    */
203   struct GNUNET_NAMESTORE_Header gns_header;
204
205   /**
206    * #GNUNET_SYSERR on failure, #GNUNET_OK on success
207    */
208   int32_t op_result GNUNET_PACKED;
209 };
210
211
212 /**
213  * Lookup a label
214  */
215 struct LabelLookupMessage
216 {
217   /**
218    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP
219    */
220   struct GNUNET_NAMESTORE_Header gns_header;
221
222   /**
223    * Length of the name
224    */
225   uint32_t label_len GNUNET_PACKED;
226
227   /**
228    * The private key of the zone to look up in
229    */
230   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
231
232   /* followed by:
233    * name with length name_len
234    */
235 };
236
237
238 /**
239  * Lookup a label
240  */
241 struct LabelLookupResponseMessage
242 {
243   /**
244    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE
245    */
246   struct GNUNET_NAMESTORE_Header gns_header;
247
248   /**
249    * Name length
250    */
251   uint16_t name_len GNUNET_PACKED;
252
253   /**
254    * Length of serialized record data
255    */
256   uint16_t rd_len GNUNET_PACKED;
257
258   /**
259    * Number of records contained
260    */
261   uint16_t rd_count GNUNET_PACKED;
262
263   /**
264    * always zero (for alignment)
265    */
266   uint16_t reserved GNUNET_PACKED;
267
268   /**
269    * The private key of the authority.
270    */
271   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
272
273   /* followed by:
274    * name with length name_len
275    * serialized record data with rd_count records
276    */
277 };
278
279
280
281 /**
282  * Lookup a name for a zone hash
283  */
284 struct ZoneToNameMessage
285 {
286   /**
287    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
288    */
289   struct GNUNET_NAMESTORE_Header gns_header;
290
291   /**
292    * The private key of the zone to look up in
293    */
294   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
295
296   /**
297    * The public key of the target zone
298    */
299   struct GNUNET_CRYPTO_EcdsaPublicKey value_zone;
300 };
301
302
303 /**
304  * Respone for zone to name lookup
305  */
306 struct ZoneToNameResponseMessage
307 {
308   /**
309    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
310    */
311   struct GNUNET_NAMESTORE_Header gns_header;
312
313   /**
314    * Length of the name
315    */
316   uint16_t name_len GNUNET_PACKED;
317
318   /**
319    * Length of serialized record data
320    */
321   uint16_t rd_len GNUNET_PACKED;
322
323   /**
324    * Number of records contained
325    */
326   uint16_t rd_count GNUNET_PACKED;
327
328   /**
329    * result in NBO: #GNUNET_OK on success, #GNUNET_NO if there were no
330    * results, #GNUNET_SYSERR on error
331    */
332   int16_t res GNUNET_PACKED;
333
334   /**
335    * The private key of the zone that contained the name.
336    */
337   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
338
339   /* followed by:
340    * name with length name_len
341    * serialized record data with rd_count records
342    */
343
344 };
345
346
347 /**
348  * Record is returned from the namestore (as authority).
349  */
350 struct RecordResultMessage
351 {
352   /**
353    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT
354    */
355   struct GNUNET_NAMESTORE_Header gns_header;
356
357   /**
358    * Name length
359    */
360   uint16_t name_len GNUNET_PACKED;
361
362   /**
363    * Length of serialized record data
364    */
365   uint16_t rd_len GNUNET_PACKED;
366
367   /**
368    * Number of records contained
369    */
370   uint16_t rd_count GNUNET_PACKED;
371
372   /**
373    * always zero (for alignment)
374    */
375   uint16_t reserved GNUNET_PACKED;
376
377   /**
378    * The private key of the authority.
379    */
380   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
381
382   /* followed by:
383    * name with length name_len
384    * serialized record data with rd_count records
385    */
386 };
387
388
389 /**
390  * Start monitoring a zone.
391  */
392 struct ZoneMonitorStartMessage
393 {
394   /**
395    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START
396    */
397   struct GNUNET_MessageHeader header;
398
399   /**
400    * #GNUNET_YES to first iterate over all records,
401    * #GNUNET_NO to only monitor changes.o
402    */
403   uint32_t iterate_first GNUNET_PACKED;
404
405   /**
406    * Zone key.
407    */
408   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
409
410 };
411
412
413 /**
414  * Start a zone iteration for the given zone
415  */
416 struct ZoneIterationStartMessage
417 {
418   /**
419    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
420    */
421   struct GNUNET_NAMESTORE_Header gns_header;
422
423   /**
424    * Zone key.  All zeros for "all zones".
425    */
426   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
427
428 };
429
430
431 /**
432  * Ask for next result of zone iteration for the given operation
433  */
434 struct ZoneIterationNextMessage
435 {
436   /**
437    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
438    */
439   struct GNUNET_NAMESTORE_Header gns_header;
440 };
441
442
443 /**
444  * Stop zone iteration for the given operation
445  */
446 struct ZoneIterationStopMessage
447 {
448   /**
449    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
450    */
451   struct GNUNET_NAMESTORE_Header gns_header;
452 };
453
454
455 GNUNET_NETWORK_STRUCT_END
456
457
458 /* end of namestore.h */
459 #endif