glitch in the license text detected by hyazinthe, thank you!
[oweals/gnunet.git] / src / namestore / namestore.h
1 /*
2      This file is part of GNUnet.
3      Copyright (C) 2011-2013 GNUnet e.V.
4
5      GNUnet is free software: you can redistribute it and/or modify it
6      under the terms of the GNU Affero General Public License as published
7      by the Free Software Foundation, either version 3 of the License,
8      or (at your 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      Affero General Public License for more details.
14 */
15
16 /**
17  * @file namestore/namestore.h
18  * @brief common internal definitions for namestore service
19  * @author Matthias Wachs
20  * @author Christian Grothoff
21  */
22 #ifndef NAMESTORE_H
23 #define NAMESTORE_H
24
25 /**
26  * Maximum length of any name, including 0-termination.
27  */
28 #define MAX_NAME_LEN 256
29
30 GNUNET_NETWORK_STRUCT_BEGIN
31
32 /**
33  * Generic namestore message with op id
34  */
35 struct GNUNET_NAMESTORE_Header
36 {
37   /**
38    * header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_*
39    * header.size will be message size
40    */
41   struct GNUNET_MessageHeader header;
42
43   /**
44    * Request ID in NBO
45    */
46   uint32_t r_id GNUNET_PACKED;
47 };
48
49
50 /**
51  * Store a record to the namestore (as authority).
52  */
53 struct RecordStoreMessage
54 {
55   /**
56    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE
57    */
58   struct GNUNET_NAMESTORE_Header gns_header;
59
60   /**
61    * Expiration time
62    */
63   struct GNUNET_TIME_AbsoluteNBO expire;
64
65   /**
66    * Name length
67    */
68   uint16_t name_len GNUNET_PACKED;
69
70   /**
71    * Length of serialized record data
72    */
73   uint16_t rd_len GNUNET_PACKED;
74
75   /**
76    * Number of records contained
77    */
78   uint16_t rd_count GNUNET_PACKED;
79
80   /**
81    * always zero (for alignment)
82    */
83   uint16_t reserved GNUNET_PACKED;
84
85   /**
86    * The private key of the authority.
87    */
88   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
89
90   /* followed by:
91    * name with length name_len
92    * serialized record data with rd_count records
93    */
94 };
95
96
97 /**
98  * Response to a record storage request.
99  */
100 struct RecordStoreResponseMessage
101 {
102   /**
103    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE
104    */
105   struct GNUNET_NAMESTORE_Header gns_header;
106
107   /**
108    * #GNUNET_SYSERR on failure, #GNUNET_OK on success
109    */
110   int32_t op_result GNUNET_PACKED;
111 };
112
113
114 /**
115  * Lookup a label
116  */
117 struct LabelLookupMessage
118 {
119   /**
120    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP
121    */
122   struct GNUNET_NAMESTORE_Header gns_header;
123
124   /**
125    * Length of the name
126    */
127   uint32_t label_len GNUNET_PACKED;
128
129   /**
130    * The private key of the zone to look up in
131    */
132   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
133
134   /* followed by:
135    * name with length name_len
136    */
137 };
138
139
140 /**
141  * Lookup a label
142  */
143 struct LabelLookupResponseMessage
144 {
145   /**
146    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE
147    */
148   struct GNUNET_NAMESTORE_Header gns_header;
149
150   /**
151    * Name length
152    */
153   uint16_t name_len GNUNET_PACKED;
154
155   /**
156    * Length of serialized record data
157    */
158   uint16_t rd_len GNUNET_PACKED;
159
160   /**
161    * Number of records contained
162    */
163   uint16_t rd_count GNUNET_PACKED;
164
165   /**
166    * Was the label found in the database??
167    * #GNUNET_YES or #GNUNET_NO
168    */
169   uint16_t found GNUNET_PACKED;
170
171   /**
172    * The private key of the authority.
173    */
174   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
175
176   /* followed by:
177    * name with length name_len
178    * serialized record data with rd_count records
179    */
180 };
181
182
183
184 /**
185  * Lookup a name for a zone hash
186  */
187 struct ZoneToNameMessage
188 {
189   /**
190    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
191    */
192   struct GNUNET_NAMESTORE_Header gns_header;
193
194   /**
195    * The private key of the zone to look up in
196    */
197   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
198
199   /**
200    * The public key of the target zone
201    */
202   struct GNUNET_CRYPTO_EcdsaPublicKey value_zone;
203 };
204
205
206 /**
207  * Respone for zone to name lookup
208  */
209 struct ZoneToNameResponseMessage
210 {
211   /**
212    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
213    */
214   struct GNUNET_NAMESTORE_Header gns_header;
215
216   /**
217    * Length of the name
218    */
219   uint16_t name_len GNUNET_PACKED;
220
221   /**
222    * Length of serialized record data
223    */
224   uint16_t rd_len GNUNET_PACKED;
225
226   /**
227    * Number of records contained
228    */
229   uint16_t rd_count GNUNET_PACKED;
230
231   /**
232    * result in NBO: #GNUNET_OK on success, #GNUNET_NO if there were no
233    * results, #GNUNET_SYSERR on error
234    */
235   int16_t res GNUNET_PACKED;
236
237   /**
238    * The private key of the zone that contained the name.
239    */
240   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
241
242   /* followed by:
243    * name with length name_len
244    * serialized record data with rd_count records
245    */
246
247 };
248
249
250 /**
251  * Record is returned from the namestore (as authority).
252  */
253 struct RecordResultMessage
254 {
255   /**
256    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT
257    */
258   struct GNUNET_NAMESTORE_Header gns_header;
259
260   /**
261    * Name length
262    */
263   uint16_t name_len GNUNET_PACKED;
264
265   /**
266    * Length of serialized record data
267    */
268   uint16_t rd_len GNUNET_PACKED;
269
270   /**
271    * Number of records contained
272    */
273   uint16_t rd_count GNUNET_PACKED;
274
275   /**
276    * always zero (for alignment)
277    */
278   uint16_t reserved GNUNET_PACKED;
279
280   /**
281    * The private key of the authority.
282    */
283   struct GNUNET_CRYPTO_EcdsaPrivateKey private_key;
284
285   /* followed by:
286    * name with length name_len
287    * serialized record data with rd_count records
288    */
289 };
290
291
292 /**
293  * Start monitoring a zone.
294  */
295 struct ZoneMonitorStartMessage
296 {
297   /**
298    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START
299    */
300   struct GNUNET_MessageHeader header;
301
302   /**
303    * #GNUNET_YES to first iterate over all records,
304    * #GNUNET_NO to only monitor changes.o
305    */
306   uint32_t iterate_first GNUNET_PACKED;
307
308   /**
309    * Zone key.
310    */
311   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
312
313 };
314
315
316 /**
317  * Ask for next result of zone iteration for the given operation
318  */
319 struct ZoneMonitorNextMessage
320 {
321   /**
322    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT
323    */
324   struct GNUNET_MessageHeader header;
325
326   /**
327    * Always zero.
328    */
329   uint32_t reserved;
330
331   /**
332    * Number of records to return to the iterator in one shot
333    * (before #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_MONITOR_NEXT
334    * should be send again). In NBO.
335    */
336   uint64_t limit;
337
338 };
339
340
341
342 /**
343  * Start a zone iteration for the given zone
344  */
345 struct ZoneIterationStartMessage
346 {
347   /**
348    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
349    */
350   struct GNUNET_NAMESTORE_Header gns_header;
351
352   /**
353    * Zone key.  All zeros for "all zones".
354    */
355   struct GNUNET_CRYPTO_EcdsaPrivateKey zone;
356
357 };
358
359
360 /**
361  * Ask for next result of zone iteration for the given operation
362  */
363 struct ZoneIterationNextMessage
364 {
365   /**
366    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
367    */
368   struct GNUNET_NAMESTORE_Header gns_header;
369
370   /**
371    * Number of records to return to the iterator in one shot
372    * (before #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
373    * should be send again). In NBO.
374    */
375   uint64_t limit;
376
377 };
378
379
380 /**
381  * Stop zone iteration for the given operation
382  */
383 struct ZoneIterationStopMessage
384 {
385   /**
386    * Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
387    */
388   struct GNUNET_NAMESTORE_Header gns_header;
389 };
390
391
392 GNUNET_NETWORK_STRUCT_END
393
394
395 /* end of namestore.h */
396 #endif