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